Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6076773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:38:46+00:00 2026-05-23T10:38:46+00:00

Is there a way to do a FishEye (or Barrel transformation) effect on a

  • 0

Is there a way to do a FishEye (or Barrel transformation) effect on a image with PHP-GD?
I found this with some code, but I have a hard time porting it to PHP.

How can I implement a fisheye lens effect (barrel transformation) in MATLAB?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:38:47+00:00Added an answer on May 23, 2026 at 10:38 am

    But – It is possible with GD and fast!! in comparison with ImageMagick
    enter image description here
    Create a new image with the size of (2*SourceWidth)/PI.
    Walk trough each pixel of the new image and find the distance from the center.
    dsource=hypot(x-centerX,y-centerY)
    Find the corresponding distance in the source image by ddest.=2*r*asin(dsource/r)/2
    r is the half width of the destination image.
    See examples with bench mark: http://meindesign.net/picture2bubble/picture2bubble.php

    function fisheye($infilename,$outfilename){
         $im=imagecreatefrompng($infilename);
         $ux=imagesx($im);//Source imgage width(x) 
         $uy=imagesy($im);//Source imgage height(y) 
         $umx=$ux/2;//Source middle
         $umy=$uy/2;
         if($ux>$uy)$ow=2*$uy/pi();//Width for the destionation image
         else $ow=2*$ux/pi();
         $out=imagecreatetruecolor($ow+1,$ow+1); 
         $trans=imagecolortransparent($out,ImageColorAllocate($out,0,0,0));
         imagefill($im,1,1,$trans); 
         for($c=0;$c<imagecolorstotal($im);$c++){//Copy palette
            $col=imagecolorsforindex($im,$c);
            imagecolorset($out,$c,$col[red],$col[green],$col[blue]);
            }
         $om=$ow/2;//destination middle
         for($x=0;$x<=$ow;++$x){//Loop X in destination image
            for($y=0;$y<=$ow;++$y){//Loop y in destination image
               $otx=$x-$om;//X in relation to the middle
               $oty=$y-$om;//Y in relation to the middle
               $oh=hypot($otx,$oty);//distance
               $arc=(2*$om*asin($oh/$om))/(2);
               $factor=$arc/$oh;
               if($oh<=$om){//if pixle inside radius
                 $color=imagecolorat($im,round($otx*$factor+$umx),round($oty*$factor+$umy));
                 $r = ($color >> 16) & 0xFF;
                 $g = ($color >> 8) & 0xFF;
                 $b = $color & 0xFF;
                 $temp=imagecolorexact($out, $r, $g, $b);
                 imagesetpixel($out,$x,$y,$temp);
                 }
               }
            }
         imagepng($out,$outfilename);
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there way to copy a file into Plone with WebDAV and have Plone
Is there way to set @include mixin(); to variable? I tried this @mixin bg-gradient($fallback,
Is there way to typecast an object to some specific type at runtime? Is
Is there way to configure the objects from inside the code rather than configuring
Is there way to set up alarm clock in my application - this means
is there way make swf like this : via AS?
Is there way in next piece of code to only get the first record?
Is there way to write some ConfigurationValidatorAttribute or in some other way that will
Is there way to realize this algorithm with mysql without 100500 queries and lots
Is there way to do something like this (MS VS 2008)? boost::bind mybinder =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.