Page 1 of 1

Posted: 2006-06-05T15:05:03-07:00
by Bonzo
I have no idea about binary data etc. but the general php format to create a thumbnail I used is :

Code: Select all

exec("/usr/local/bin/convert -size {$size[0]}x{$size[1]} $original_image -thumbnail $max_widthx$max_height $new_image");
This was written to be used with a form. I found it hard to save to the same name in the same folder.

You can see the output plus some code on my website; nothing fancy mostly Anthonys examples demonstrated with a bit of php.

www.rubblewebs.co.uk/imagemagick/


Anthony

Posted: 2006-06-05T17:49:57-07:00
by ridera
Bonzo's code appears to have an error.

$max_widthx$max_height should be

{$max_width}x{$max_height}

Posted: 2006-06-06T11:13:13-07:00
by Bonzo
I think my code is OK ridera; I only needed the { } around the array variables but not the normal variables.
I will check again later; if I get time !

I am not sure exactly about this noodleboy but the \ tells the code that the comand carries onto the next line as you say.
A couple of things I would try is build up the code bit by bit and see where if fails + change this line \( +clone -shadow 60x4+4+4 \) to ( +clone -shadow 60x4+4+4 )

Anthony

Posted: 2006-06-06T11:50:20-07:00
by Bonzo
My code does work OK ridera 8)

Out of interest I have just tried out a creating a thumbnail using ImageMagick and GD. There does not look a lot of difference to me !
The IM version looks to contain a bit more colour.

http://www.rubblewebs.co.uk/imagemagick ... ompair.php

Anthony

Posted: 2006-06-06T12:25:05-07:00
by Bonzo
I am glad to have been of help David.

There is so much to learn with ImageMagick and I am just trying things out a bit at a time.

Anthony

Posted: 2006-06-06T12:51:04-07:00
by Bonzo
I would try saving the path to a variable then using the variable in the code.

Code: Select all

$new_name = '/home/user/public_html/temp/temp_image.jpg';

exec("/usr/local/bin/convert $file -thumbnail 100x100 $new_name"); 
I used to think you had to use the full path from server root but am not sure now. All the examples I have done so far I have saved to the same folder.

Anthony

Posted: 2006-06-06T13:52:26-07:00
by Bonzo
One step forward one step back !

I put loads of echo statements in my code when I get a problem like that as it tells you what each variable contains.

Looks like in your case you seem to have lost the file extension somewhere as its trying to open /tmp/phphHd66D which is not an image.

I would put

Code: Select all

$original_image = $_FILES["userfile"]["tmp_name"];
echo "original_image = ".$original_image."<br>;
Then you know what is in the variable. You can do that down the page with other variables as well.

Anthony

Posted: 2006-06-08T17:32:03-07:00
by ridera
here is how I set up my commands. Insures my syntax is correct.

Code: Select all

$IMresize_command_array= array(												//order is important
		'-colors'			=> 60,
		'-resize'			=> "{$IMresize_args['new_width']}x{$IMresize_args['max_height']}",
		'-quality'		     => 90,
		'-filter'			=> 'Mitchell',
		'-sharpen'		    => "0.0x1.0",
		'-white-threshold'	=> 90%,	
	);
	
	$command_str='';
	foreach($IMresize_command_array as $key => $value){
		$IMresize_command .= "$key $value ";	
	}//end foreach
	
	$IMresize_command .= $IMresize_args['output_format'];