Get image size from handler

前端 未结 2 865
说谎
说谎 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.

提交回复
热议问题