Solved

Imagemagick and setting up the maximum area of thumbnail

Posted on 2007-11-14
6
192 Views
Last Modified: 2010-04-21
Hi,

I have this command:

convert $src -quality 90 -resize 580x580 -colorspace RGB -density 72x72 -units PixelsPerInch $dst

Is there a way to specify that I want an image to be resized to 50% but the resulting image should not exeed 500X500, so if the 50% is bigger then it should bring it down to fit to 500X500?

Thanks,
John
0
Comment
Question by:infodigger
  • 3
  • 3
6 Comments
 
LVL 21

Expert Comment

by:nizsmo
ID: 20288388
are you executing this command in PHP or through commandline?
0
 

Author Comment

by:infodigger
ID: 20288463
Through php (shell_exec)
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20288469
and I assume the $src variable is the path to the image?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:infodigger
ID: 20288514
Yes, $src and $dst are paths of original image and converted image.
0
 
LVL 21

Accepted Solution

by:
nizsmo earned 500 total points
ID: 20297072
Not sure if this is what you want, but here it is see if you get what I am trying to do.
You have to fill in the commands though since I am not entirely sure of the exact commands.
<?php

	$src = "images/picture.jpg";

	$result = getimagesize($src);

	

	if(($result[0]/2) > 500 || ($result[1]/2) > 500) // checking if 50% is bigger than 500x500 (both x and y has to be under 500)

	{

		$execute_string = "COMMAND HERE FOR IF THE IMAGE AFTER 50% IS BIGGER THAN 500x500";

	}

	else 

	{

		$execute_string = "COMMAND HERE FOR IF THE IMAGE AFTER 50% IS NO BIGGER THAN 500x500";

	}

	

	shell_exec($execute_string);

?>

Open in new window

0
 

Author Closing Comment

by:infodigger
ID: 31409164
Hi nizsmo,

Yes, that was what I was looking for, but never thought of it like that:)

Thanks,
John
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now