GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Who knows PHP & ImageMagick well? (https://gfy.com/showthread.php?t=460239)

bangman 04-26-2005 05:27 AM

Who knows PHP & ImageMagick well?
 
I'm need a very minor thing changed in a php script.
It would take like 10 seconds for someone who knows PHP and ImageMagick, but I don't. If anyone feels like helping me, get me on ICQ or post here.
Thanks.

Nathan 04-26-2005 05:28 AM

What do you need?

bangman 04-26-2005 05:34 AM

I installed a simple gallery script into my WordPress, and everything works fine. I just want to change the way the ImageMagick thumbs the full-size pics.
In the script you can change the thumb size. Say I set it to 110x170 and the full-size pic is 600x200 - when you load it up, it thumbs the image to fit the height, not the width.
I want it to fit the width.
Make sense? :)

Code:

generateImg($_GET['file'], $_GET['thumb']);

function generateImg($img, $thumb) {
       
        global $gallery_root, $pictwidth, $pictheight, $thumbwidth, $thumbheight;
               
        if($thumb) {
        $height = $thumbheight;
        $width = $thumbwidth;
        } else {
        $height = $pictheight;
        $width = $pictwidth;
        }
       
        $img = $gallery_root.$img;
        $path = pathinfo($img);
        switch(strtolower($path["extension"])){
                case "jpeg":
                case "jpg":
                        Header("Content-type: image/jpeg");
                        $img=imagecreatefromjpeg($img);
                        break;
                case "gif":
                        Header("Content-type: image/gif");
                        $img=imagecreatefromgif($img);
                        break;
                case "png":
                        Header("Content-type: image/png");
                        $img=imagecreatefrompng($img);
                        break;
                default:
                        break;                       
        }
        $xratio = $width/(imagesx($img));
        $yratio = $height/(imagesy($img));

        if($xratio < 1 || $yratio < 1) {
                if($xratio < $yratio)
                        $resized = imagecreatetruecolor($width,floor(imagesy($img)*$xratio));
                else
                        $resized = imagecreatetruecolor(floor(imagesx($img)*$yratio), $height);
               
                imagecopyresampled($resized, $img, 0, 0, 0, 0, imagesx($resized)+1,imagesy($resized)+1,imagesx($img),imagesy($img));
                       
                imagejpeg($resized);
                imagedestroy($resized);
        }
        else
        {
                imagejpeg($img);
        }
        imagedestroy($img);               
}


bangman 04-26-2005 05:35 AM

The above code snippet is the php file that creates the thumbs.

bangman 04-26-2005 05:39 AM

Nevermind...i'm just an idiot. :(


All times are GMT -7. The time now is 02:07 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123