从处理程序获取图像大小 [英] Get image size from handler

查看:121
本文介绍了从处理程序获取图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在JS / PHP中创建一个图像编辑器,但现在我遇到了麻烦。首先,我从数据库加载图像(使用imagecreatefromstring加载blob)。然后我将一个动作列表应用于此图像。但是,如何从这个图像处理程序中获取图像大小呢?无需将其写入文件或使用流对象。怎么??

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 a list of actions to this image. But how can I get the image size from this image handler I have then? Without writing it to a file or use a stream object. How??

推荐答案

如果你的意思是图像尺寸:

In case you mean the image dimensions:

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

参见 imagesx() imagesy()

如果你的意思是filesize,如果不将GD资源转换为某种图像格式(GIF,PNG,JPEG),这是不可能的,因为格式决定了图像大小(以字节为单位)。

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.

这篇关于从处理程序获取图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆