PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
The code on my site takes an image and resizes it if its too large. However the resulting image is pixely; its worse than it should be for the resize. Is their another function or what that can do what I need with better quality?
Your best bet is to see if your server/host has Image Magick on the server. It is a much better way to deal with converting/resizing already present images. GD tends to degrade images when it does resizing or ratio resizes. Look into Image Magick at http://www.imagemagick.org
Okay I now have image magick installed, but have no clue how to use it. I'm looking for sometype of tutorials or code I can use, using Image Magick that will resize an image and save it as whatever I name it. Image Magick's tutorials on their website showed the syntax but gave no examples of it's implementation.
All help is appreciated!
-Ace
<?php
exec("convert //action you want IM to do -size //Tells it to set to size $thumbsize //Thumbsize variable $abpath/$img1_orig//absoulte path to orig image -resize// Resize $thumbsize//To thumbsize $abpath/$img1_thumbnail_name//absolute path and new file name of resized image");
?>
Why can't this just work, its driving me crazy!
I did what DSM said (thanks for the help by the way DSM) and although im not getting any errors, the new image does not upload to the site. Here is my code, PLEASE HELP!
//$temp stri holds info for the exec command
$temp_str = "convert -size 250x100 $imgfile1 -resize 250x100 $img1";
//I will show the output of this command in a sec
echo "Temp String = $temp_str";
//the actual execution
exec($temp_str);
Heres the output from the 'echo "Temp String = "$temp_str";':
"Temp String = convert -size 250x100 /tmp/phpxd77x2 -resize 250x100 ./images/142a.jpg".
Could someone please help.
-Ace
<?php
$abpath = "/home/my domain/www/html/images/upload"; //Absolute path to where images are uploaded. No trailing slash
$im_convert = "/usr/bin/convert"; //Where Image Magick resides on the server, and the command I want to run
$thumbsize = "75x75";
$mediumsize = "200x200";
$largesize = "600x600";
$img_1_orig = "my_pic.jpg";
$img1_thumbnail_name = "my_thumb.jpg";
exec("$im_convert -size $thumbsize $abpath/$img1_orig -resize $thumbsize $abpath/$img1_thumbnail_name");
?>
Upload your image, copy it, rename it, then run IM on it.
If you still have probs, email me and I'll help out, but i will not do it for you. It took me a few tries to get it right.