开发者

Resize image in PHP from blob in mysql

开发者 https://www.devze.com 2023-02-24 16:47 出处:网络
I have a large image I want to resize while keep开发者_高级运维ing the proportions$blob = mysql_fetch_...();

I have a large image I want to resize while keep开发者_高级运维ing the proportions


   $blob = mysql_fetch_...();

   $gd = imagecreatefromstring($blob);
   $resized = imagecreatetruecolor(X, Y); // new image dimensions
   imagecopyresampled(....);

   ob_start();
   imagejpeg($resized);
   $new_blob = ob_get_clean();

   mysql_query(... update table ...);


There are innumerable image resize scripts out there (google keywords: php thumbnailer). Alternatively roll your own using GD. Load the blob into a string, and use the imagecreatefromstring() function to create the image.

0

精彩评论

暂无评论...
验证码 换一张
取 消