Page 2 of 2

Re: Upload form with IMagick

Posted: 2012-10-17T09:31:20-07:00
by Bonzo
NOTE:- depending on your specified sizes for the original thumbnail etc. this will all need to change so everything fits. But see if you get a result from this:

Code: Select all

$new_image = $arr['img_src'];
####CROP | RESIZE THE THUMBNAIL TO 450x450 | ADD BORDER 50x50####

$save_to = $uploaddir.$thumbnail;

exec("/usr/bin/ImageMagick_6.2.6/bin/convert $new_image -crop {$height}x{$width}+$x+$y -resize 450x450  -bordercolor black -border 50x50 $save_to");

echo "<img src=\"$save_to\">";

####ADD FULLSIZED WATERMARK-IMAGE####

// The watermak to add - probably with a transparent background
$input1 = 'watermark.png';

// Resize the watermark 
exec("/usr/bin/ImageMagick_6.2.6/bin/convert $input1 -resize 450x450 temp.png");

// Not sure if you can save over the original but that can be tested later
$watermarked = $uploaddir."watermarked.jpg";

exec("/usr/bin/ImageMagick_6.2.6/bin/composite -watermark 80% -gravity center $temp $save_to $watermarked");

echo "<img src=\"$watermarked\">"; 

Re: Upload form with IMagick

Posted: 2012-10-17T13:01:54-07:00
by bruno1970
I get the error message
Undefined variable: thumbnail
and i have no idea how to define $thumbnail (after hours of try&error). :?

Code: Select all

$new_image = $arr['img_src'];
####CROP | RESIZE THE THUMBNAIL TO 450x450 | ADD BORDER 50x50####

$save_to = $uploaddir.$thumbnail;
$arr['img_src'] is not only the filename. It is the the path and filename (uploads/big/44c8168a8a8cd7117f891dd.jpg). Is that the problem?

Re: Upload form with IMagick

Posted: 2012-10-17T13:31:13-07:00
by Bonzo
I had assumed you were creating $thumbnail somewhere in you main piece of code.

echo your variables to see what they contain.

One thing I always recomend to people is get your code working with fixed variables, everything in the same folder and then build it into a form or expand on it when it is working.

Re: Upload form with IMagick

Posted: 2012-10-17T15:29:17-07:00
by bruno1970
.

Re: Upload form with IMagick

Posted: 2012-10-17T17:45:33-07:00
by bruno1970
I have found the problem!

This code works:

Code: Select all

$new_image = $arr['img_src'];
####CROP | RESIZE THE THUMBNAIL TO 450x450 | ADD BORDER 50x50####
$save_to = $uploaddir.$orginal;

exec("/usr/bin/ImageMagick_6.2.6/bin/convert $new_image -crop {$height}x{$width}+$x+$y -resize 450x450  -bordercolor black -border 50x50 $save_to");

echo $save_to;
The problem is that $arr['img_src'] is the path and the filename (uploads/big/44c8168a8a8cd7117f891dd.jpg).
The thumbnails are now in the folder uploads/thumb/uploads/big/ :lol:

Re: Upload form with IMagick

Posted: 2013-03-13T08:16:09-07:00
by bruno_1970
Hello,

i have a new problem.

Code: Select all

$new_image = $ordner.$new_name;
			
		   } while(file_exists($new_image));
			if(@move_uploaded_file($myFILE['tmp_name'], $ordner.$new_name)){
			
                       $new_image2 = $new_image;

			exec("/usr/bin/ImageMagick_6.2.6/bin/convert $new_image -thumbnail 700x700 -extent 750x750 -density 300 $new_image2");
			exec("/usr/bin/ImageMagick_6.2.6/bin/mogrify $new_image2 -format jpg $new_image2");

			echo $new_image2; 	
If i upload a JPG everything works fine but if i upload a GIF or PNG "echo $new_image2" shows never the (always) wanted JPG version. How can i fix that?

P.S.
The script creates a JPG and a GIF or PNG version in the right folder.
1b041446e51713f5ddde52a88cd4fb9c.jpg
1b041446e51713f5ddde52a88cd4fb9c.gif