Solved

Imagemagick and setting up the maximum area of thumbnail

Posted on 2007-11-14
6
214 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

790 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