Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Imagemagick and setting up the maximum area of thumbnail

Posted on 2007-11-14
6
Medium Priority
?
234 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.
Suggested Courses

636 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