Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
Jaepee

Rotating Images Making Thumbnails

Recommended Posts

Hi everyone, hope all is well.

 

First, I wanted to say thanks again to Larry for making his books and supporting them with this forum. Second, thanks to all the active forum members and all of their support, while I haven't been posting that much I do find myself coming to the forums quite often to read and learn as much as I can. I have learned leaps and bounds. I also try and help out other forum users when I can.

I was looking at my phpinfo(); function and saw a class that appears to come with the php installation.

It is called IMAGICK. I read on the php.net page about some of the methods that come with this class and started to code a simple image Rotation script and a Thumbnail generation script.

 

My question, is it perfectly safe to use IMAGICK vs. Writing my own scripts to handle rotation and thumbnail generation. Does anyone have any suggestions on my code to make better?

 

Here is a simple sample code that I wrote using some functions on the php.net page

 

http://www.php.net/manual/en/class.imagick.php

 

$image = new Imagick("/home/{$JAEPEE}/public/{$user_folder}/{$main_pic}"); // main image
$thumb = new Imagick("/home/{$JAEPEE}/{$folder}/thumbs/{$thumb}");  // thb
// this code rotates an image ... //
$image->rotateImage(new ImagickPixel(), $degrees); // main 180 flip // 270 rotate left // rotate right //
$thumb->rotateImage(new ImagickPixel(), $degrees); // thb// 180 -> flip//  270 -> rotates left // 90 -> rotates right //

// thumbnail code ...
//$image1->thumbnailImage(150,150,true); // creates thumbnail to size 150
//$image1->cropThumbnailImage(150,150); // crops and keeps aspect ratio

// writes image to folder
$m = $image->writeImage("/home/{$JAEPEE}/public/{$user_folder}/{$main_pic}");
$t = $image1->writeImage("/home/{$JAEPEE}/public/{$user_folder}/thumbs/{$thumb}"); // saves the thumbnail at the given destination
if ($t && $m) {
echo 'Image was rotated';
} else {
echo 'No go on the rotate';
}

 

The rotate feature works pretty darn good, and it's really fast too.

Thanks Everyone

jp

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...