Jump to content

imagetruecolortopalette


drisate

Recommended Posts

Hey guys ... is there any other way of doing this with out using imagetruecolortopalette? The qualaty output is awful ...

 

                       $simg = imagecreatefromjpeg("$idir" . $url);
                        $currwidth = imagesx($simg); 
                        $currheight = imagesy($simg); 
                        if ($currheight > $currwidth) { 
                            $zoom = $twidth / $currheight; 
                            $newheight = $theight; 
                            $newwidth = $currwidth * $zoom; 
                        } else { 
                            $zoom = $twidth / $currwidth; 
                            $newwidth = $twidth; 
                            $newheight = $currheight * $zoom; 
                        }
                        $dimg = imagecreate($newwidth, $newheight); 
                        imagetruecolortopalette($simg, false, 256);
                        $palsize = ImageColorsTotal($simg);
                        for ($i = 0; $i < $palsize; $i++) { 
                            $colors = ImageColorsForIndex($simg, $i); 
                            ImageColorAllocate($dimg, $colors['red'], $colors['green'], $colors['blue']); 
                        }
                        imagecopyresized($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight); 
                        imagejpeg($dimg, "$tdir" . $url); 
                        imagedestroy($simg); 
                        imagedestroy($dimg); 

Link to comment
https://forums.phpfreaks.com/topic/160070-imagetruecolortopalette/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.