无法在PHP中从MIME类型为'image/x-ms-bmp'的BMP创建GD图像​​资源 [英] Unable to create GD image resource from BMP with MIME type 'image/x-ms-bmp' in PHP

查看:215
本文介绍了无法在PHP中从MIME类型为'image/x-ms-bmp'的BMP创建GD图像​​资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从BMP图像创建GD图像​​资源,但是我没有运气.

I'm trying to create a GD image resource from a BMP image, however I'm having no luck.

有问题的BMP图像是用Photoshop创建并保存的.我也尝试了一些在网络上发现的BMP,它们给出了相同的结果.

The BMP image in question was created and saved with Photoshop. I've tried a couple of BMPs I found on the web too, and they gave the same results.

getimagesize()告诉我BMP图像的图像类型为IMAGETYPE_BMP(6),MIME类型为'image/x-ms-bmp'.

getimagesize() tells me the BMP image has an image type of IMAGETYPE_BMP (6) and a MIME type of 'image/x-ms-bmp'.

我尝试通过imagecreatefromwbmp()和imagecreatefromxbm()运行图像,但是都无法识别.我也尝试过通过imagecreatefromstring()运行它,但是该错误提示数据不是可识别的格式".

I've tried running the image through imagecreatefromwbmp() and imagecreatefromxbm(), but neither recognise it. I've also tried running it through imagecreatefromstring(), but that errored saying 'Data is not in a recognized format'.

我在启用了WBMP和XBM支持的PHP 5.3.1和GD 2.0.34的Windows机器上运行XAMPP.我也在运行PHP 5.2.6和GD 2.0.34且启用了WBMP和XBM支持的Linux服务器上尝试了此操作.

I'm running XAMPP on a Windows machine with PHP 5.3.1 and GD 2.0.34 with WBMP and XBM support enabled. I've also tried this on a Linux server running PHP 5.2.6 and GD 2.0.34 with WBMP and XBM support enabled, same result.

有什么想法可以从该BMP创建GD图像​​资源吗?真的有可能吗?

Any ideas how I can create a GD image resource from this BMP? Is it actually possible?

推荐答案

据我所知,它不支持BMP图像. imagecreatefromwbmp()方法用于处理无线位图(WBMP)文件,而不是在那里的普通BMP. imagecreatefromxbm()用于处理XBM格式(同样,不同于BMP).

As far as I know, it doesn't support BMP images. The imagecreatefromwbmp() method is for dealing with wireless bitmaps (WBMP) files, not the normal BMP you have there. The imagecreatefromxbm() is for dealing with the XBM format (again, different from BMP).

我将通过重新打开Photoshop并将其另存为PNG或JPG来解决此问题.假设您已经安装了PHP/使用相应的支持对其进行了编译,那么您将可以很好地使用其中一种或两种图像格式.

I would work around this by re-opening Photoshop and re-saving as PNG or JPG. Assuming you have PHP installed/compiled with the appropriate support, you'll be able to work with one or both of those image formats fine.

这篇关于无法在PHP中从MIME类型为'image/x-ms-bmp'的BMP创建GD图像​​资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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