Get image size from handler

前端 未结 2 845
说谎
说谎 2021-01-12 23:25

I\'m creating an image editor in JS/PHP, but now I\'m having trouble. First of all, I load the image from the database (load a blob with imagecreatefromstring). Then I apply

相关标签:
2条回答
  • 2021-01-12 23:41

    In case you mean the image dimensions:

    $width  = imagesx($imgHandle);
    $height = imagesy($imgHandle);
    

    See imagesx() and imagesy().

    If you mean filesize, that's not possible without converting the GD resource to some image format (GIF, PNG, JPEG) because the format determines the image size in bytes.

    0 讨论(0)
  • 2021-01-12 23:53

    I doubt you can since php gd image object is a generic object, without considerations on the compression that will be used for storage (png/jpg/bmp ...)

    0 讨论(0)
提交回复
热议问题