Fredrik
Fredrik

Reputation: 1312

Resize image in PHP from blob in mysql

I have a large image I want to resize while keeping the proportions

Upvotes: 1

Views: 3197

Answers (2)

Marc B
Marc B

Reputation: 360802

   $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 ...);

Upvotes: 3

preinheimer
preinheimer

Reputation: 3722

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.

Upvotes: 0

Related Questions