Solved

Imagemagick and setting up the maximum area of thumbnail

Posted on 2007-11-14
6
200 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Select from sql by results from textbox 8 26
File submission to SQL Server 1 38
updating the date data 12 20
Scope of $_SESSION 17 25
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

914 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

19 Experts available now in Live!

Get 1:1 Help Now