[wp-hackers] Crop a picture

Nathaniel Taintor goldenapplesdesign at gmail.com
Sat Sep 4 17:52:25 UTC 2010


If you want to do it in PHP, look into the ImageGD library. Its included
with almost all PHP5 installations that I've seen. Your code would look
something like this, to crop a 100px square from the top left of your
original gif:

$image = imagecreatefromgif( $url_to_src );
$cropped = imagecreatetruecolor( 100, 100 );
imagecopy( $cropped, $image, 0, 0, 0, 0, 100, 100 );
imagegif( $cropped );

More info: http://www.php.net/manual/en/ref.image.php

But I'm not sure why you couldn't just do it with css, either using the clip
property, or just displaying your image in a div with overflow set to
hidden.


On Sat, Sep 4, 2010 at 1:19 AM, Ryan Bilesky <rbilesky at gmail.com> wrote:

> I did end up finding some javascript code for the expanded popup.  But I
> have still been unable to find some code that will take in a .gif image and
> crop it (from top left corner) then output the cropped thumbnail image.
>
> On Fri, Sep 3, 2010 at 6:10 PM, Ryan Bilesky <rbilesky at gmail.com> wrote:
>
> > I am looking for a script to use with a plugin I am writing that will
> take
> > an image stored on the server, and show me a cropped version. Then when I
> > put my mouse over the cropped version, the full version displays is some
> > popup panel that just goes right over the site and disappears when my
> mouse
> > moves off of it.
> >
> > So it will need to be some combination of php and javascript. Is anyone
> > aware of such a script?
> >
>


More information about the wp-hackers mailing list