Re: [PHP] Image Manipulation
At 7:16 PM -0500 11/9/08, Ron Piggott wrote: Is there a way to find out the number of pixels wide and high an image is in PHP? Is there a way to resize an image using PHP? Ron Yes tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Manipulation
Ron Piggott schreef: Is there a way to find out the number of pixels wide and high an image is in PHP? Is there a way to resize an image using PHP? heh Ron, you've been around this list long enough to know that you should STFW and RTFM before posting questions. http://www.google.com/search?q=php+image+size lo and behold the first result item. the way it goes is like this, every time you think 'hey can I do that' there is a very big chance some 12yo has already done it, blogged about it, posted code on phpclasses.org (or some such place) and printed a T-Shirt to celebrate the fact ... I know this from experience (not because I'm the 12yo .. although some might say so) Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Manipulation
On Sun, 2008-11-09 at 19:16 -0500, Ron Piggott wrote: Is there a way to find out the number of pixels wide and high an image is in PHP? Is there a way to resize an image using PHP? Ron Yes. Look at the PHP GD manual. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image manipulation on the fly
Hi Merlin, that is very fast for 1024 images, you will not get much more speed if you try doing anything smarter , though there are some image libraries that are faster than GD libs eg www.imagemagick.org On Nov 8, 2007, at 5:13 PM, Merlin wrote: Hi there, I need to manipulate images on the fly. My goal is to make the image very bright, or to add a sepia effect. The problem is, that this takes a lot of computing power on 1024 pictures. About 2s on my server until the image is delivered. Does anybody know a high performing image funtion that would allow me to brighten up the picture on the fly, or any other effect similar to it? I am attaching the sepia function I am using. Thank you for any help or suggestion on how to solve that. Best regards, Merlin function image_effect_sepia($im){ $start_red = 2; //red scale at black $start_blue = 2.3; //blue scale at black $red_scale = ($start_red-1)/256;//red modifier as greyscale goes to white $blue_scale = ($start_blue - 1)/256;//ditto for blue //build a sepia lookup table $sepia = array(); for($x = 0;$x 256;$x++){ $red = intval($x * ($start_red - ($x * $red_scale))); if($red 255) $red = 255; $blue = intval($x / ($start_blue - ($x * $blue_scale))); $sepia[$x][0] = $red; $sepia[$x][1] = $blue; } # modify the image for($y = 0;$y imagesy($im);$y++){ for($x = 0;$x imagesx($im);$x++){ $pixel = imagecolorat($im, $x, $y); $red = ($pixel 0xFF) 16; $green = ($pixel 0x00FF00) 8; $blue = $pixel 0xFF; $alpha = $pixel 0x7F00; //get a greyscale value $gs = intval(($red * 0.3) + ($green * 0.59) + ($blue * 0.11)); $p = $alpha | $sepia[$gs][1] | ($gs 8) | ($sepia[$gs] [0] 16); imagesetpixel ($im, $x, $y, $p); } } # return the moddifyed image return $im; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Bojan Tesanovic http://www.classicio.com/
Re: [PHP] Image manipulation on the fly
Merlin wrote: Hi there, I need to manipulate images on the fly. My goal is to make the image very bright, or to add a sepia effect. The problem is, that this takes a lot of computing power on 1024 pictures. About 2s on my server until the image is delivered. Yeah, you're doing CPU-intensive stuff in an interpreted language - it'll never be efficient unless you write it in C or similar. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image manipulation with php
On 8/29/06, Ross [EMAIL PROTECTED] wrote: I have an saved images I output with this... img src=includes/viewphoto.php?id=?=$photo? I want to use getimagesize() to get the height and width of the image and if it is above a certain size then scale/ reduce it. The problems are (i) using getimage() without a url just my viewphoto.php script I'm not sure what you mean here. (ii) comparing and reducing the file reducing a file tends to follow the logic of some sort: $size = GetImageSize ($image); $ratio = $size[0]/$size[1]; if ($ratio 1) { $width = $max_size; $height = ($max_size/$size[0]) * $size[1]; } else { $width = ($max_size/$size[1]) * $size[0]; $height = $max_size; } where $max_size is the largest you want your image to be in width, then just copy it it into a new image create at that size There are a lot of samples of this on google as jochem suggested. Curt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image manipulation with php
Ross wrote: I have an saved images I output with this... img src=includes/viewphoto.php?id=?=$photo? I want to use getimagesize() to get the height and width of the image and if it is above a certain size then scale/ reduce it. The problems are (i) using getimage() without a url just my viewphoto.php script why is this a problem? getimagesize() just needs a path to the image. given that this is all new to you you might consider that storing the image data directly in the DB is best left to crazy fools who really know where their towels are at. (ii) comparing and reducing the file RTFM or STFW - there are lots of examples related to image resampling/thumbnailing/etc and even more readymade scripts that do more or less what you want. Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image manipulation without GD library
Tim Burgan wrote: Hello, Is there any way that I can do some image manipulation - resizing - without the GD libraries? Can you execute imagemagic's mogrify? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image manipulation without GD library
Tim Burgan wrote: Is there any way that I can do some image manipulation - resizing - without the GD libraries? You can use ImageMagik (aka 'convert') through http://php.net/exec if ImageMagik is installed, and the PHP user can run it. I'm guessing that the same could be said for the GIMP though I've never seen it done -- or *any* command-line based image manipulation tool I've never heard of for that matter. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Manipulation
Yes there is way, search for GD in the php manual, it will explain a solution better than i will. Jason GH [EMAIL PROTECTED] wrote: I would like to know if there is a way to have PHP determine the dimensions of an image (i.e. JPG or PNG) and if it more than Xpx wide or height have it scale it down proportionally to that width or height? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Manipulation
I would like to know if there is a way to have PHP determine the dimensions of an image (i.e. JPG or PNG) and if it more than Xpx wide or height have it scale it down proportionally to that width or height? look at http://us4.php.net/gd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image manipulation in PHP
On Tuesday 20 July 2004 19:28, Mark Collin wrote: Is there any support for TGA images in PHP. Not builtin. I have searched through the PHP manual and through the GD library website and cannot even find a reference to TGA, is there no support for TGA images in PHP at all? (this seems rather strange as TGA is quite a commonly used GFX format) Probably because PHP is web-oriented and TGA is not supported by most browsers. Have a look at Imagick and netpbm. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* World War Three can be averted by adherence to a strictly enforced dress code! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image manipulation in PHP
Thanks for the advice, I will look into it. Jason Wong [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]: On Tuesday 20 July 2004 19:28, Mark Collin wrote: Is there any support for TGA images in PHP. Not builtin. I have searched through the PHP manual and through the GD library website and cannot even find a reference to TGA, is there no support for TGA images in PHP at all? (this seems rather strange as TGA is quite a commonly used GFX format) Probably because PHP is web-oriented and TGA is not supported by most browsers. Have a look at Imagick and netpbm. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image manipulation
Hi tux, For your second question, try: http://www.linuxfocus.org/English/July2001/article211.shtml It'll give some basci info on image manipulation using ImageMagick. Hth, Andre On Sunday 01 September 2002 01:19 pm, tux wrote: Hey all, I was just wondering if anyone could recommend any tutorials or books or functions i should look into, to do the following: - decrease the size(kilobytes wise not height/width) of an image - imprint a transparent logo onto every picture displayed any feedback greatly appreciated. jo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image manipulation with PHP on RHLinux 7.1
Ok, I've been looking at the image functions, and found that I needed to recompile PHP with exif support and load GD and other functions. I've done all of that and now I get the following: Source: /home/jamboimages/images/uploads/alamoarea_97_round_sm.jpg 600 : /images/patches/1997/1997R15.jpg 300 : /images/patches/1997/1997R15_sm.jpg Width = 600 Height = 580 Fatal error: Call to undefined function: exif_imagetype() in /home/jamboimages/admin/review_patches.php on line 69 The partial code in my webpage is (code borrowed from the PHP site, and modified). Any help is appreciated. If you want to see the phpinfo, go to: http://dreamer.propagation.net/phpinfo.php Here's the code... /* resize_to_file resizes a picture and writes it to the harddisk * * $sourcefile = the filename of the picture that is going to be resized * $six_file = File name of the 600-pixel-wide file * $three_file = File name of the 300-pixel wide file */ function resize_to_file ($sourcefile, $six_file, $three_file) { print Source: $sourcefileBR; print 600 : $six_fileBR; print 300 : $three_fileBR; $picsize = getimagesize($sourcefile); $width = $picsize[0]; $height = $picsize[1]; print Width = $widthBR; print Height = $heightBR; $image_type = exif_imagetype($sourcefile); print Image: $image_typeBR; ... more code here to resize the image file ... ... and write it to a new location on disk ... } -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Dale Lora MarshallInternet Marketing Services http://lonestar.texas.net/~marshal1 http://www.internet-ms.com [EMAIL PROTECTED][EMAIL PROTECTED] [EMAIL PROTECTED] -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image manipulation with PHP on RHLinux 7.1
exif_imagetype() is new function only available in PHP 4.2 (not released yet) and above. Use GetImageSize() for now. -Rasmus On Sat, 30 Mar 2002, Dale Lora Marshall wrote: Ok, I've been looking at the image functions, and found that I needed to recompile PHP with exif support and load GD and other functions. I've done all of that and now I get the following: Source: /home/jamboimages/images/uploads/alamoarea_97_round_sm.jpg 600 : /images/patches/1997/1997R15.jpg 300 : /images/patches/1997/1997R15_sm.jpg Width = 600 Height = 580 Fatal error: Call to undefined function: exif_imagetype() in /home/jamboimages/admin/review_patches.php on line 69 The partial code in my webpage is (code borrowed from the PHP site, and modified). Any help is appreciated. If you want to see the phpinfo, go to: http://dreamer.propagation.net/phpinfo.php Here's the code... /* resize_to_file resizes a picture and writes it to the harddisk * * $sourcefile = the filename of the picture that is going to be resized * $six_file = File name of the 600-pixel-wide file * $three_file = File name of the 300-pixel wide file */ function resize_to_file ($sourcefile, $six_file, $three_file) { print Source: $sourcefileBR; print 600 : $six_fileBR; print 300 : $three_fileBR; $picsize = getimagesize($sourcefile); $width = $picsize[0]; $height = $picsize[1]; print Width = $widthBR; print Height = $heightBR; $image_type = exif_imagetype($sourcefile); print Image: $image_typeBR; ... more code here to resize the image file ... ... and write it to a new location on disk ... } -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Dale Lora MarshallInternet Marketing Services http://lonestar.texas.net/~marshal1 http://www.internet-ms.com [EMAIL PROTECTED][EMAIL PROTECTED] [EMAIL PROTECTED] -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Manipulation/GD support
At 8:17 PM -0800 23/3/02, Rasmus Lerdorf wrote: failing. I use gd2 these days because the 8-bit limitation of gd1 just sucks. You can find my simple gd2 instructions here http://www.php.net/~rasmus/gd.html I found that enabling GD and freetype support in php-4.1.2 was not this simple. php-4.1.2 seems to require gd-2.0.2 which has not yet been released. Here's a description of how I got it working: http://mel01.juggernaut.com.au/patches/gd/ ...Richard. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image manipulation with PHP on RHLinux 7.1
I guess I should clarify. If the image that's referenced in the database is, for example, 700x300, I want to reduce it to 600 pixels wide, keeping the height proportional. Then, save that image to a new name somewhere else in the filesytem. Then I want to reduce the image further to 300 pixels wide, again keeping the height proportional. And save that image elsewhere. Ideas? - Dale At 3/24/02 06:30 PM, you wrote: This isn't image manipulation. This is filesystem manipulation. As for the resizing, check if you have mogrify with you Linux installation and do a system() on it. cheers, --t. On Sun, 24 Mar 2002, Dale Lora Marshall wrote: Hello all. I have a PHP script which retrieves records from a database, and one field in the record is the path to an image. I want to do things with this image: See what it's size (pixes) is Resize it if necessary Move it to a different location Can someone give me an idea on how to do this? I'm running PHP 4.1.2 on Red Hat Linux 7.1 Thanks! - Dale -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Dale Lora MarshallInternet Marketing Services http://lonestar.texas.net/~marshal1 http://www.internet-ms.com [EMAIL PROTECTED][EMAIL PROTECTED] [EMAIL PROTECTED] -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Dale Lora MarshallInternet Marketing Services http://lonestar.texas.net/~marshal1 http://www.internet-ms.com [EMAIL PROTECTED][EMAIL PROTECTED] [EMAIL PROTECTED] -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image manipulation with PHP on RHLinux 7.1
On Monday 25 March 2002 08:06, Dale Lora Marshall wrote: I guess I should clarify. If the image that's referenced in the database is, for example, 700x300, I want to reduce it to 600 pixels wide, keeping the height proportional. Then, save that image to a new name somewhere else in the filesytem. Then I want to reduce the image further to 300 pixels wide, again keeping the height proportional. And save that image elsewhere. Manual Image functions -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* The light at the end of the tunnel may be an oncoming dragon. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Manipulation/GD support
Try image/jpeg as your content-type On Sat, 23 Mar 2002, Navid Yar wrote: Hello, I just enabled GD support for PHP via the php.ini file. When I try to run a script that uses the functions included in the library, it gives me a dialog box asking me whether I want to save the php file to a specific location or not. I don't need to save it, I need PHP to run it. This is happening on two machines enabled with the gd library. I'm using PHP 4.0.6, while my remote host machine is using 4.1.1. Do I need a more current version of the GD library to run this script? Here is the script: ?php $image = images/pic.jpg; if (!$max_width) $max_width = 150; if (!max_height) $max_height= 150; $size = GetImageSize($image); $width = $size[0]; $height = $size[1]; $x_ratio = $max_width / $width; $y_ratio = $max_height / $height; if (($width = $max_width) ($height = $max_height)) { $tn_width = $width; $tn_height = $height; } elseif (($x_ratio * $height) $max_height) { $tn_height = ceil($x_ratio * $height); $tn_width = $max_width; } else { $tn_width = ceil($y_ratio * $width); $tn_height = $max_height; } $src = ImageCreateFromJpeg ($image); $dst = ImageCreate ($tn_width, $tn_height); ImageCopyResized ($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height); header (Content-type: image/jpg); ImageJpeg ($dst, null, -1); ImageDestroy ($src); ImageDestroy ($dst); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Image Manipulation/GD support
Rasmus, thanks so much! It's executing. I've run into another problem with this script, but I'll try to figure this one out as best I can first before posting it. Thanks again! :) -Original Message- From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Sent: Saturday, March 23, 2002 4:41 PM To: Navid Yar Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Image Manipulation/GD support Try image/jpeg as your content-type On Sat, 23 Mar 2002, Navid Yar wrote: Hello, I just enabled GD support for PHP via the php.ini file. When I try to run a script that uses the functions included in the library, it gives me a dialog box asking me whether I want to save the php file to a specific location or not. I don't need to save it, I need PHP to run it. This is happening on two machines enabled with the gd library. I'm using PHP 4.0.6, while my remote host machine is using 4.1.1. Do I need a more current version of the GD library to run this script? Here is the script: ?php $image = images/pic.jpg; if (!$max_width) $max_width = 150; if (!max_height) $max_height= 150; $size = GetImageSize($image); $width = $size[0]; $height = $size[1]; $x_ratio = $max_width / $width; $y_ratio = $max_height / $height; if (($width = $max_width) ($height = $max_height)) { $tn_width = $width; $tn_height = $height; } elseif (($x_ratio * $height) $max_height) { $tn_height = ceil($x_ratio * $height); $tn_width = $max_width; } else { $tn_width = ceil($y_ratio * $width); $tn_height = $max_height; } $src = ImageCreateFromJpeg ($image); $dst = ImageCreate ($tn_width, $tn_height); ImageCopyResized ($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height); header (Content-type: image/jpg); ImageJpeg ($dst, null, -1); ImageDestroy ($src); ImageDestroy ($dst); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Manipulation/GD support
On the topic of gd support but a slightly different topic- I was using php 4.0.5 gd 1.8.3 patched for gif support (using libungif for libgif which I *think* is OK) FreeType 1.3.1 (compiled myself in /usr/local ) t1lib 1.3.1 (compiled myself in /usr/local ) I was using gd to draw pictures and write text on them with ttf fonts. I saw there were some new image functions in = 4.0.6 so I grabbed the latest php I use a script to compile php same compile options, but t1lib gave a ptoblem because instead of looking in /usr/local/lib it tried to find the library in /usr/lib/.libs the configure option id --with-t1lib=/usr/local cd /usr/lib ln -s /usr/local/lib .libs took care of that but I really don't want to do that. Anyway, my big problem is with freetype. compiled I could draw and open images, but could not write ttf fonts on them. reading the ./configure -h I see that they CHANGED what the configure options mean. now --with-freetype=dir refers to freetype 2 Personally I think its insane to change the meaning of a configure option, but OK. So I downloaded FreeType 2 and compiled it and installed in /usr/local recompiled php Still can't use ttf to write on images. phpinfo() says I have FreeType linkage. But both ImageFtText and ImageTTFText fail to do anything. What is up with that? Perl is losing popularity because every time it updates scripts frequently need some rewriting (that and cpan will grab the latest module and then try to grab a newer perl instead of grabbing the module that works with the installed perl- g) Hopefully php isn't going that route. Is this just a bug or has there been a major change? I'm going to have to find myself trying php 4.0.6 and possibly reverting back to 4.0.5 if I can't get this resolved. My compile options are here- http://macaddict4life.dhs.org/info.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Manipulation/GD support
reading the ./configure -h I see that they CHANGED what the configure options mean. now --with-freetype=dir refers to freetype 2 Untrue, it only refers to freetype2 when you are building against GD2. phpinfo() says I have FreeType linkage. But both ImageFtText and ImageTTFText fail to do anything. What is up with that? Perl is losing popularity because every time it updates scripts frequently need some rewriting (that and cpan will grab the latest module and then try to grab a newer perl instead of grabbing the module that works with the installed perl- g) Hopefully php isn't going that route. Is this just a bug or has there been a major change? I'm going to have to find myself trying php 4.0.6 and possibly reverting back to 4.0.5 if I can't get this resolved. Works just fine for me. Play with your config.log and see what is failing. I use gd2 these days because the 8-bit limitation of gd1 just sucks. You can find my simple gd2 instructions here http://www.php.net/~rasmus/gd.html -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IMAGE Manipulation
Hey, I'm not sure if anyone ever answered your question, but here's a little function I wrote for something similar to what you want to do and it doesn't require GD be installed. You need to modify the top portion, I just threw that in there to show you how it would work. $pic is the name of the image you want to display. $largestside is the largest width/height you'll want to be shown - So if the max height or width is supposed to only be 200, you'd set it to that, then it scales the other side so that it displays with the correct dimensions. This doesn't ACTUALLY resize the file, it just takes the image and then in HTML it sets the height and width. If you need to actually resize the file you will need GD to be installed. Hope this helps in some way! ?php $pic = image.jpg; $dimensions = resize($pic); echo img src=\$pic\ width=\$dimensions[0]\ height=\$dimensions[1]\ function resize($v_pic) { $largestside = 120; $size = GetImageSize ($v_pic); $width = $size[0]; $height = $size[1]; if ($width == $height) { $dimensions[0] = $largestside; $dimensions[1] = $largestside; } elseif ($width $height) { $divisor = $width / $largestside; $height = $height / $divisor; $dimensions[1] = intval ($height); $dimensions[0] = $largestside; } elseif ($width $height) { $divisor = $height / 120; $width = $width / $divisor; $dimensions[0] = intval ($width); $dimensions[1] = 120; } return $dimensions; } On Saturday 16 March 2002 04:56 am, you wrote: Hi, I'm trying to resize images from a big image to smaller image in dimension and also file size so that when a user upload an image into server, when a browser display the picture it desn't have to be as big. I hope my question make sense. I just don't know where to start. may be somebody could help me, please. thank you for reviewing my email. regards, Dani -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image manipulation
Adam - If you're on a machine that has ImageMagick installed on it (most Linux boxes I've been on have it installed already) you can do something like this in PHP: $origfile = /home/bob/my_face.jpg; $img_dir = /usr/local/www/htdocs/images; $dest_file = $img_dir . /t_ . basename($userfile) . .gif; $s = system (/usr/X11R6/bin/convert -geometry 100x100 $userfile $dest_file); will create a 100x100 pixel thumbnail image called t_my_face.jpg.gif in /usr/local/www/htdocs/images ImageMagick can be found at http://www.imagemagick.org/ Have fun! -bob -- Bob Scott Web / DB Developer http://www.covalent.netCovalent Technologies, Inc. On Fri, 31 Aug 2001, Adam Plocher wrote: Hey I got a few questions about image manipulation. First of all, is there anyway I could have my script take a full size image and crop out a chunk of it to be used as a thumbnail - or just simply shrink the image down to be used as a thumbnail? Also, is there anyway to convert misc image types (gif, bmp, png, etc) into a jpeg? Any help will be very appreciated, thanks. -Adam Plocher -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Image manipulation
www.php.net/GetImageSize list($width, $height) = getimagesize(file.gif); /* Chris Lambert, CTO - [EMAIL PROTECTED] WhiteCrown Networks - More Than White Hats Web Application Security - www.whitecrown.net */ - Original Message - From: Kevin Pratt [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 10, 2001 1:04 PM Subject: [PHP] Image manipulation | Does any one know if you can check the dimensions of a GIF file? | | Thanks | Kevin | | | -- | PHP General Mailing List (http://www.php.net/) | To unsubscribe, e-mail: [EMAIL PROTECTED] | For additional commands, e-mail: [EMAIL PROTECTED] | To contact the list administrators, e-mail: [EMAIL PROTECTED] | | | -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]