Page 2 of 2

Re: Best way to reduce file size/resolution on upload?

Posted: 2010-10-25T13:47:49-07:00
by Bonzo
Check my site there is loads of php stuff there.

Try:

Code: Select all

<?php 
echo "<pre>"; 
system("type convert");  
echo "</pre>"; 
?> 
OR
<?php 
echo "<pre>"; 
system('which convert',$path); print_r($path);  
echo "</pre>"; 
?> 

Re: Best way to reduce file size/resolution on upload?

Posted: 2010-10-25T16:36:53-07:00
by fmw42
which convert as above will tell you where IM is installed and what version to use.

using Bonzo's code, my command would look like

Code: Select all

<?php 
$array=array(); 
echo "<pre>"; 
exec("convert -define jpeg:size=300x300 inputimage -resize 300x300 -depth 8 -quality 75 -density 72 -units pixelsperinch resultimage 2>&1", $array);  
print_r($array);  
echo "</pre>"; 
?> 
The $array and print_r($array) will collect any errors and send them to the display. You will have to open the image separately as this only creates it and does not display it. However, Bonzo has code to do that and you should look over his site, if you want a pure PHP solution.

Note that in the code window above the convert command is really one long line and not split into two lines as the code window show it.

Re: Best way to reduce file size/resolution on upload?

Posted: 2010-10-25T16:38:30-07:00
by raindance
Thanks to you both...will pass along....I really appreciate it!

Re: Best way to reduce file size/resolution on upload?

Posted: 2010-10-26T00:17:45-07:00
by anthony
See IM Examples... Thumbnails Which provides all the details on this and more.

Re: Best way to reduce file size/resolution on upload?

Posted: 2010-10-26T08:34:21-07:00
by raindance
He says he tried this:

<?php
$array=array();
echo "<pre>";
exec("convert -define jpeg:size=300x300 http://www.juicyhotels.com/images/manual_images/mia.jpg -resize 300x300 -depth 8 -quality 75 -density 72 -units 72 http://www.juicyhotels.com/images/manua ... s/mia2.jpg 2>&1", $array);
print_r($array);
echo "</pre>";
?>

And this was the result:

Array
(
[0] => sh: convert: command not found
)


Any idea?

Re: Best way to reduce file size/resolution on upload?

Posted: 2010-10-26T08:37:21-07:00
by raindance
Does that mean we dont have IM installed correctly?

Re: Best way to reduce file size/resolution on upload?

Posted: 2010-10-26T09:32:59-07:00
by Bonzo
It might be or it might not - how about getting him to run the code I posted above. You may need to use the full path to convert in your code and this code will tell you what it is.

Code: Select all

<?php 
echo "<pre>"; 
system("type convert");  
echo "</pre>"; 
?> 
OR
<?php 
echo "<pre>"; 
system('which convert',$path); print_r($path);  
echo "</pre>"; 
?> 


Re: Best way to reduce file size/resolution on upload?

Posted: 2010-10-26T09:35:28-07:00
by raindance
I think he thought he did...
Server company says its installed right...dev is working on it...sent him your code...thanks. He thinks maybe he got it done.

Re: Best way to reduce file size/resolution on upload?

Posted: 2010-10-26T10:01:50-07:00
by fmw42
typical paths to convert are

/usr/local/bin/convert

or

/usr/bin/convert

You may have to use the correct one in your PHP exec command. But the which convert command should tell you where IM convert is located exactly if it is really installed.

Re: Best way to reduce file size/resolution on upload?

Posted: 2010-10-26T11:30:42-07:00
by raindance
He got it :-)
Thanks everyone for your help! I aprpeciate it very much.