I have a image uploading webiste... I am facing 2 problems in it... 1) I don't want user to upload a image which has single quote(') or Double Quotes(") in the file name. ex. jonn'simage.jpg... I tried using (strstr($imagename,'\'')) and (strstr($imagename,'\"')) function but it isn't working.. 2) Image Resizing : i want to display the image within 750xX px box, ie, width=750px and height can vary... so when the image is of dimension 800x500px, then i want that its width reduces to 750px and its height varies in ratio with its width but if the image has dimensions 500x400px or 400x800px then i dont want to change anything in the image and want to displat it as it is... Can anyone help???
Resizing can be done via imagemagick like: exec("convert image.jpg -resize 750x resize_image.jpg"); PHP: Usually you need to provide full path to initial and result images. I usually use str_replace(); PHP: to replace some symbols in string.
Thnkyou Ashine for repling my query.. The 2nd part of my 2nd question still remains unanswered... How can i change the height of the image with accordance to the width using the function you provided..
Using imagemagick (convert is a part of it) you don't have to provide height by yourself. Height will be computed automatically to match new width and keep aspect ratio. See http://www.imagemagick.org/script/command-line-processing.php#geometry fro details.
I am going through the link you provided me but i am not getting how to use it... what is the code and how to write it in php...??? can you please help me
Ok, examples: function ConvertUsingOnlyWidth($from, $to, $max_width = 0) { exec("convert " . $from . " +profile \"*\" " . "-resize \"" . $max_width .">\" " . $to); } PHP: this will resize image only if its width is bigger than $max_width function ConvertUsingOnlyWidth($from, $to, $max_width = 0) { exec("convert " . $from . " +profile \"*\" " . "-resize \"" . $max_width ."\" " . $to); } PHP: this will resize iamge in any case, so it will enlarge small images and shrink big ones. Usage: $path = "/mounted-storage/home1s8b/sub005/sc30r21-RGCK/site.info/"; ConvertUsingOnlyWidth($path."shine.jpg",$path."tmp/shine.jpg",800); PHP: Make sure your tmp directory is writeable by script.