Solved

Imagemagick and setting up the maximum area of thumbnail

Posted on 2007-11-14
6
228 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
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 dynamically set the form action using jQuery.
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.

717 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