vbnullchar Posted November 9, 2006 Share Posted November 9, 2006 is there a way to resize an image without using gd then output a thumbnailed image.thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/26671-image-resize-without-using-gd/ Share on other sites More sharing options...
heckenschutze Posted November 9, 2006 Share Posted November 9, 2006 Yes but its a hell of a lot of work :)One method is to; Write the image parsers yourself, which would mean handling binary data inside your script... this also means you'd need to also write/use a zip decompressor/compressor if you wanted to I/O PNGs.Or you could search for other Perl/PHP Modules, possibly use ImageMagiK (sp?)hth Quote Link to comment https://forums.phpfreaks.com/topic/26671-image-resize-without-using-gd/#findComment-122012 Share on other sites More sharing options...
vbnullchar Posted November 9, 2006 Author Share Posted November 9, 2006 heres the configure command my webhost used [code]'./configure' '--enable-ftp' '--enable-mysql' '--with-mysql' '--with-zlib' '-with-apxs2=/usr/local/apache2/bin/apxs'[/code]can u suggest somethng? Quote Link to comment https://forums.phpfreaks.com/topic/26671-image-resize-without-using-gd/#findComment-122014 Share on other sites More sharing options...
Vikas Jayna Posted November 9, 2006 Share Posted November 9, 2006 Do you have the [b]ImageMagick[/b] library installed on the server. In case you do, then the [b]convert command[/b] can be called from within php using [b]passthru function[/b] like this:[code]passthru("/usr/bin/convert -resize 30x30 image.jpg -");[/code]this will output the thumbnail of size 30x30 to the browser. image.jpg should be an image file on the disk. Quote Link to comment https://forums.phpfreaks.com/topic/26671-image-resize-without-using-gd/#findComment-122066 Share on other sites More sharing options...
roadhead Posted November 10, 2006 Share Posted November 10, 2006 [quote author=Vikas Jayna link=topic=114369.msg465394#msg465394 date=1163071834]Do you have the [b]ImageMagick[/b] library installed on the server. In case you do, then the [b]convert command[/b] can be called from within php using [b]passthru function[/b] like this:[code]passthru("/usr/bin/convert -resize 30x30 image.jpg -");[/code]this will output the thumbnail of size 30x30 to the browser. image.jpg should be an image file on the disk.[/quote]What if my image is stored in a MySQL database base64 encoded? Quote Link to comment https://forums.phpfreaks.com/topic/26671-image-resize-without-using-gd/#findComment-122796 Share on other sites More sharing options...
Vikas Jayna Posted November 11, 2006 Share Posted November 11, 2006 decode the image with [b]base64_decode()[/b] and then write it to a temporary file on the disk (say image.jpg). In case you do not wish to write the file on the disk, then the code would look something like this:[code]$fp=popen("/usr/bin/convert -resize 30x30 - -");fwrite($fp,$imagecontent);pclose($fp);[/code]Here the command uses an additional [b]hyphen[/b] which means that the input image will come from standard input stream i.e. the content writen by [b]fwrite[/b] function Quote Link to comment https://forums.phpfreaks.com/topic/26671-image-resize-without-using-gd/#findComment-123012 Share on other sites More sharing options...
kenrbnsn Posted November 11, 2006 Share Posted November 11, 2006 If the images come from a recent digital camera, you may be able to use one of the [url=http://www.php.net/exif]exif[/url] functions, especially the [url=http://www.php.net/exif_thumbnail]exif_thumbnail()[/url] function which extracts the embedded thumbnail from the full size picture.Ken Quote Link to comment https://forums.phpfreaks.com/topic/26671-image-resize-without-using-gd/#findComment-123015 Share on other sites More sharing options...
marknt Posted November 11, 2006 Share Posted November 11, 2006 [code]<?phpfunction imageResize($width, $height, $target) {if ($width > $height) { $percentage = ($target / $width);} else { $percentage = ($target / $height);}//gets the new value and applies the percentage, then rounds the value$width = round($width * $percentage);$height = round($height * $percentage);//returns the new sizes in html image tag format...this is so you//can plug this function inside an image tag and just get thereturn "width=\"$width\" height=\"$height\"";} $pic = "./images/picture.jpg";$mysock = getimagesize($pic);$var = imageResize($mysock[0], $mysock[1], 150);?><img src="<?=$pic?>" <?=$var?>>[/code]It worked for me promise. It feels good to help someone. I have learned the hard way when I'm still starting as a PHP Developer. Quote Link to comment https://forums.phpfreaks.com/topic/26671-image-resize-without-using-gd/#findComment-123060 Share on other sites More sharing options...
heckenschutze Posted November 11, 2006 Share Posted November 11, 2006 The image is still going to have the same size, byte wise...Not sure that's what he's after. :) Quote Link to comment https://forums.phpfreaks.com/topic/26671-image-resize-without-using-gd/#findComment-123064 Share on other sites More sharing options...
marknt Posted November 11, 2006 Share Posted November 11, 2006 [quote author=heckenschutze link=topic=114369.msg466406#msg466406 date=1163230963]The image is still going to have the same size, byte wise...Not sure that's what he's after. :)[/quote]Yes you are correct. Same size but in thumbnail view. For example resize it by minus 25% but same size Quote Link to comment https://forums.phpfreaks.com/topic/26671-image-resize-without-using-gd/#findComment-123068 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.