Is there a way to incorporate the drop shadow command into this?Bonzo wrote:You will need some sort of code to tell php what to do. I put mine in an upload form and resize on upload.
You can resize "on the fly" using something like:
PUT THIS ON A PAGE OF ITS OWN AND CALL thumbnail.phpCall from your page using:Code: Select all
<?php $photo = $_GET['p']; $height = '125'; $width = '200'; $cmd = "convert $photo -thumbnail {$width}x{$height} JPG:-"; header("Content-type: image/jpeg"); passthru($cmd, $retval); ?>
Code: Select all
<img src="thumbnail.php?p=input.jpg">
Newbie here needs help
Re: Newbie here needs help
Re: Newbie here needs help
Code: Select all
<?php
$photo = 'original.jpg';
$height = '125';
$width = '200';
$cmd = "convert $photo -matte -thumbnail {$width}x{$height} ( +clone -background black -shadow 90x3+15+15 ) +swap -gravity northwest -geometry -3-3 -composite -background white -flatten +repage PNG:-";
header("Content-type: image/jpeg");
passthru($cmd, $retval);
?>
You may need to use \( \) rather than ( )
Re: Newbie here needs help
Is there some reason the pics are not thumbnailed to the exact size? I notice some pics are off a few pixels here or there.
Does it depend on the original size pic or something in the command?
For example setting the width and height to 180x270 of a pic 900x1316 -
Imagemagick thumnails it to: 180x263
Does it depend on the original size pic or something in the command?
For example setting the width and height to 180x270 of a pic 900x1316 -
Imagemagick thumnails it to: 180x263
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Newbie here needs help
IM tries to preserve the aspect ratio of images, so that circles remain circles!
If that is not wanted add a '!' flag to the resize/thumbnail option.
Otherwise you can pad out the image using techniques given in
Im Examples, Thumbnails, Padding
If that is not wanted add a '!' flag to the resize/thumbnail option.
Otherwise you can pad out the image using techniques given in
Im Examples, Thumbnails, Padding
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Newbie here needs help
Well, I just added the image attributes in the image tags and it resizes automatically. Guess, its a good idea to do that.anthony wrote:IM tries to preserve the aspect ratio of images, so that circles remain circles!
If that is not wanted add a '!' flag to the resize/thumbnail option.
Otherwise you can pad out the image using techniques given in
Im Examples, Thumbnails, Padding

Re: Newbie here needs help
Another question
In the above php code, 'thumbnail' is used.
Does that give less quality compared to 'resize'?
Which is better and how would I use resize in that code?
Thanks!

In the above php code, 'thumbnail' is used.
Does that give less quality compared to 'resize'?
Which is better and how would I use resize in that code?
Thanks!
Re: Newbie here needs help
I think the quality of thumbnail and resize is the same. Thumbnail strips out all the EXIF data automaticaly where as with resize you need to use -strip.
To use resize just swap the words.
To speed up jpg resizing try changing:
To
To use resize just swap the words.
To speed up jpg resizing try changing:
Code: Select all
$cmd = "convert $photo -matte -thumbnail {$width}x{$height}
Code: Select all
$cmd = "convert -size {$width}x{$height} $photo -matte -thumbnail {$width}x{$height}
Re: Newbie here needs help
Is there a way to incorporate two commands into one php?
For instance use the above to resize but then add a shadow and convert to png?
I found this drop shadow code but not sure what to do with it, lol.
Basically I want to resize an image down to 80x120, add a drop shadow with an offset of 8 (for both x and y), blur radius 15 and opacity 80. This makes the image 110x150. Would save me some time instead of using The Gimp.
For instance use the above to resize but then add a shadow and convert to png?
I found this drop shadow code but not sure what to do with it, lol.
Basically I want to resize an image down to 80x120, add a drop shadow with an offset of 8 (for both x and y), blur radius 15 and opacity 80. This makes the image 110x150. Would save me some time instead of using The Gimp.

Code: Select all
convert -page +4+4 thumbnail.gif -matte \
\( +clone -background navy -shadow 60x4+4+4 \) +swap \
-background none -mosaic shadow_soft.png
Re: Newbie here needs help
You know what I am having a hard time figuring out (surprise!) is the quality command.
I cant seem to get it to be equivalent to of say 85 (of a photo program like the gimp).
I cant seem to get it to be equivalent to of say 85 (of a photo program like the gimp).
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Newbie here needs help
IM quality factors may not be truly linear percents.
Re: Newbie here needs help
I kinda figured something out, I just exported (from a pdf) the original image at smaller scale. So that worked.
Speaking of that is there a way to use imagemagick to export pdf to jpg?
Speaking of that is there a way to use imagemagick to export pdf to jpg?
Re: Newbie here needs help
Try this code - its one I used for a website just change the values to what you want:
To convert a pdf you use the same code as normal but you need ghostscript installed:
To control the quality a bit more add a density:
To just convert the second page ( note the first page is 0 I think not 1 ):
Code: Select all
exec("convert $value -matte -resize 560x450 \( +clone -background black -shadow 90x3+15+15 \) +swap -gravity northwest -geometry -3-3 -composite -background white -flatten +repage $photo");
Code: Select all
exec("convert input.pdf output.jpg");
Code: Select all
exec("convert -density 300 input.pdf output.jpg");
Code: Select all
exec("convert input.pdf[1] output.jpg");
Re: Newbie here needs help
Ok, I messed something up:Bonzo wrote:Try this code - its one I used for a website just change the values to what you want:Code: Select all
exec("convert $value -matte -resize 560x450 \( +clone -background black -shadow 90x3+15+15 \) +swap -gravity northwest -geometry -3-3 -composite -background white -flatten +repage $photo");
Here is my php:
Code: Select all
<?php
$photo = $_GET['p'];
$height = $_GET['h'];
$width = $_GET['w'];
$cmd = "/usr/local/bin/convert exec("convert $value -matte -resize 960x1457 \( +clone -background black -shadow 90x3+15+15 \) +swap -gravity northwest
-geometry -3-3 -composite -background white -flatten +repage $photo");
passthru($cmd, $retval);
?>
Code: Select all
SRC="resizepic.php?p=images/xxxx.jpg&w=960&h=1457"
Re: Newbie here needs help
My code was to save an image to do what you want try this:
Code: Select all
<?php
$photo = $_GET['p'];
$height = $_GET['h'];
$width = $_GET['w'];
$cmd = "/usr/local/bin/convert $photo -matte -resize {$width}x{$height} \( +clone -background black -shadow 90x3+15+15 \) +swap -gravity northwest
-geometry -3-3 -composite -background white -flatten +repage ";
passthru($cmd, $retval);
?>