this doesn't work because of the backslash inside the double quote
exec("convert $file -resize 100x100\> $destination");
I've tried inserting {} and \ and even \\ with no success!
exec("convert $file -resize 100x100{\}> $destination"); //failed!
exec("convert $file -resize 100x100\\\> $destination"); //failed!
exec("convert $file -resize 100x100\\> $destination"); //failed!
I know i'm close, but i can't find it! What is it ?? Thanks
If you need to put a backslash inside a text, then you should write \\
. Then you're writing a backslash (escape) and then writing a backslash.
If you really need the backslash, try something like this (with single quotes):
exec('convert '.$file.' -resize 100x100\> '.$destination);
Quote the argument:
exec("convert $file -resize '100x100>' $destination");
I replaced exec with echo to see what string you end up with:
$destination='something';
echo "convert $file -resize 100x100\\> $destination";
echo "<br>
";
echo "convert $file -resize 100x100\\> $destination";
echo "<br>
";
echo "convert $file -resize 100x100\\\> $destination";
output:
convert -resize 100x100\> something
convert -resize 100x100\> something
convert -resize 100x100\\> something
So the problem seems to be in the command itself.
I'd put the string together like this though:
$ex_string='convert '.$file.' -resize 100x100\> '.$destination;
after many many testing and reading, i've found the solution for those that are interested
test1
$from = 'c:/fc_gallery/test.jpg'; //image size: 662 x 960
$to = 'c:/public_html/gallery/images/test.jpg';
exec("convert -resize 100x100 $from $to"); //produces a thumbnail of 62x100, keeps aspect ratio
test2
$from = 'c:/fc_gallery/test.jpg'; //image size: 1874 x 1430
$to = 'c:/public_html/gallery/images/test.jpg';
exec("convert -resize 100x100 $from $to"); //produces a thumbnail of 100x76, keeps aspect ratio
I was surprised that i didn't need the backslash(\) or the greater sign(>) to keep the aspect ratio! I'm using imagemagick version 6.8.6-Q16... and, for those that are interested,i'm reading the book The Definitive Guide To ImageMagick