Jump to content

Image Resize & Rotation


uzeshan

Recommended Posts

Hi

 

I have 2 scripts, one for Image rotation and other image resize and they both are working.

 

Image resize scripts load the picture and resize it to "Thumbnail" and Image rotation rotate the image by 90 deg. They are two differennt files i.e. resize.php and rotate.php.

 

What I want to do is to combine both rotate.php & resize.php, so when the scripts resize the image than it call rotate script to rotate the image display it on the screen.. I hope I am making sence.. I am finding hard to explain.. If u dont understand anything please let me know..

 

thanks

Zee

Link to comment
Share on other sites

why don't you just use imagerotate() in your image resize script. Just add it to the end after you have created the thumbnail. This however will not effect the original image which when clicked on will still be the original way.

 

Ray

Link to comment
Share on other sites

here is the code for resize.php ==>

 

*************************************

<?php

$src_img = imagecreatefrompng('image.png');

$srcsize = getimagesize('image.png');

$dest_x = 200;

$dest_y = (200 / $srcsize[0]) * $srcsize[1];

$dst_img = imagecreatetruecolor($dest_x, $dest_y);

imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0,

$dest_x, $dest_y, $srcsize[0], $srcsize[1]);

header("content-type: image/png");

imagepng($dst_img);

imagedestroy($src_img);

imagedestroy($dst_img);

?>

********************************************

 

Here is the code for rotate.php  ==>

                                              ***********************************************

 

<?php

// File and rotation

$filename = 'test.jpg';

$degrees = 180;

 

// Content type

header('Content-type: image/jpeg');

 

// Load

$source = imagecreatefromjpeg($filename);

 

// Rotate

$rotate = imagerotate($source, $degrees, 0);

 

// Output

imagejpeg($rotate);

?>

**********************************

thanks

Link to comment
Share on other sites

here is the right code for rotate.php

 

****************************

 

<?php

// File and rotation

$filename = 'image.png';

$degrees = 18;

 

// Content type

header('Content-type: image/png');

 

// Load

$source = imagecreatefrompng($filename);

 

 

// Rotate

$rotate = imagerotate($source, $degrees, 0);

 

// Output

imagepng($rotate);

?>

******************

thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.