Jump to content

[SOLVED] help with images


WebDevon

Recommended Posts

I have search around for a bit and cant really find the answer to this.  If anyone has a free moment a little help would be greatly appreciated.  Thanks in advance....

 

I would like to create 2 additional images from an image that I have uploaded.

 

the first additional image is to be 33% of the uploaded image size and saved to images/main

while the 2nd image is to be 16% of the uploaded image size and saved to image/list

 

the file is uploaded under $_FILES["file"]["name"] (files are already filtered out by jpg/gif only)

 

Thanks so much :), and please if you know of another place where this is answered please post the URL and i will immediately close this topic.

Link to comment
https://forums.phpfreaks.com/topic/41161-solved-help-with-images/
Share on other sites

hmmmmmmm  ok.

 

Could you give me a sample line that would do such a thing?

 

my line of thinking from the research iv done was a little off.  I was thinking that i could get the original H X W and then go something like

 

$n_height = imagesx($file) * 33

$n_wid..... etc..

 

However during that call i receive an error stating call to invalid function or unknown function, something along those lines.

 

Assuming it's a jpg, here's code to creat the 33% version

 

<?php
$fn = $_FILES['file']['name'];
$im = imagecreatefromjpeg($_FILES['file']['tmp_name']); //uploaded file
$iw = imagesx($im);
$ih = imagesy($im);

$iw33 = $iw*0.57;
$ih33 = $ih*0.57;
$im33 = imagecreatetruecolor($iw33, $ih33);
imagecopyresampled($im33, $im, 0,0,0,0,$iw33,$ih33,$iw,$ih);
// output to file
imagejpeg($im33, 'full/path/to/file/'.$fn, 100);
imagedestroy($im);
imagedestroy($im33);
?>

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.