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
https://forums.phpfreaks.com/topic/94269-image-resize-rotation/
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
https://forums.phpfreaks.com/topic/94269-image-resize-rotation/#findComment-483736
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
https://forums.phpfreaks.com/topic/94269-image-resize-rotation/#findComment-483762
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.