Thumbnailing with php code?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
acctman

Thumbnailing with php code?

Post by acctman »

hi how would i use the imagemagick command line code that i got from the user section in php

If i read the manual correctly this should keep the sizing within the aspect ratio right? height of 125px with a max width of 190px

convert large.jpg -auto-orient -thumbnail 190x125 tn_small.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Thumbnailing with php code?

Post by fmw42 »

-thumbnail 190x125 will scale to 190 (assuming your image width>height)

-thumbnail 190x125^ will scale to 125 (assuming your image width>height)

on windows you need ^^ (as ^ is an escape character)

see http://www.imagemagick.org/script/comma ... php#resize (-thumbnail should follow the same scheme as -resize)
acctman

Re: Thumbnailing with php code?

Post by acctman »

i'm still unsure as to how to use this in PHP coding.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Thumbnailing with php code?

Post by fmw42 »

can't help you there. hopefully someone else can or try your question on one of the IM PHP forums.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Thumbnailing with php code?

Post by anthony »

See Rubble Web for examples of using command line IM from PHP scripts.
http://www.rubblewebs.co.uk/imagemagick/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Thumbnailing with php code?

Post by Bonzo »

Just back from holiday; did you get this sorted ?
acctman

Re: Thumbnailing with php code?

Post by acctman »

Bonzo wrote:Just back from holiday; did you get this sorted ?
i tried this code with no luck

exec("convert -thumbnail 190x125 -auto-orient -quality 75 -strip watermarked.jpg tn_small.jpg");

maxwidth 190 and maxheight 125
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Thumbnailing with php code?

Post by Bonzo »

Versions after 6. something need the image reading in first.
-thumbnail strips the image anyway so you do not need -strip
-auto-orient only works if the image has the option ?

So I would try:

Code: Select all

exec("convert watermarked.jpg -thumbnail 190x125 -quality 75 tn_small.jpg");
What do you mean when you say its not working?
acctman

Re: Thumbnailing with php code?

Post by acctman »

Bonzo wrote:Versions after 6. something need the image reading in first.
-thumbnail strips the image anyway so you do not need -strip
-auto-orient only works if the image has the option ?

So I would try:

Code: Select all

exec("convert watermarked.jpg -thumbnail 190x125 -quality 75 tn_small.jpg");
What do you mean when you say its not working?
i changed it to resize and move the quality after the main image and everything works now

Code: Select all

exec("convert watermarked.jpg -quality 75 -resize 190x125 tn_small.jpg");
Post Reply