Save image from one format to another with php gd2

后端 未结 3 1755
梦谈多话
梦谈多话 2021-01-23 08:10

I have a database with a column filled with image binaries data. After I made some research I figuried out how to detect in which image format is the data. Lets say in of the re

3条回答
  •  没有蜡笔的小新
    2021-01-23 08:47

    I think you'll need to do the following for each image:

    • Write out the BLOB image data to a file
    • Open the image in gd with imagecreatefromgif()
    • Write the image back out to the disk with imagejpeg()
    • Read in the image data from file and write it back to the database

    In general terms keeping image data in the database like this is bad practice. A nicer solution is to store the images on the webserver disk but to store the file location to the images in the database. If for example you'd done this it'd be a lot easier for you to fix the problem that your explaining!

提交回复
热议问题