2
votes

This is the first time I use PHP Imagick and experiencing problems with it.

I'm creating a website module where users can upload images that need to be converted to an encrypted file type containing the uploaded image as a DDS texture.

So what I need to do is convert the uploaded image to dds file format.

Code:

$img = new Imagick('test.png'); //Load the uploaded image
$img->setformat('dds'); //Set the format to dds
$img->setImageCompression(Imagick::COMPRESSION_DXT3); //Set compression method
$img->writeimage('test.dds'); //Write/save the dds texture

The problem: the output file is always an empty, 0 byte file.

PNG That needs to be converted: test.png

DDS That needs to be the output: test.dds

Maybe I need other version Imagick or ImageMagick?

My old version of these are:

  1. PHP 5.5.15
  2. Imagick 3.1.2-5.5-ts-vc11-x86
  3. ImageMagick 6.8.4-0-Q16-x86

I am currently testing on Windows 8.1 x64.

Any suggestion/help would be appreciated.

Edit: Edited the question, hopefully its clear now what I am trying to achieve.

Solved: The problem was the version of ImageMagick that had no support for DDS write.

Installed ImageMagick 6.8.6-10-Q16-x86 since the DDS write support was added in that version (newer versions caused the imagick not to be loaded).

Current version of what I use and works:

  1. PHP 5.5.15
  2. Imagick 3.1.2-5.5-ts-vc11-x86
  3. ImageMagick 6.8.6-10-Q16-x86
1
Please can you rewrite your question; it is very unclear what you are actually trying to do. You don't need to give a long description, you just need to give the code you're using, maybe a link to an example image file if you think it is necessary, and a description of how the code doesn't do what you're expecting. - Danack
Hello, Thanks for the comment. Edited the question (added input/output image links as well), hopefully its clear now what I am trying to achieve. - Acnathon
Can you check if "\Imagick::queryformats();" lists DDS as a supported format. Your code works fine for me on a Centos box. - Danack
I just checked and yes it is listed. Imagick::queryformats(); Output Could be something related to the version I have installed(?) - Acnathon
Maybe. Can you run the command through ImageMagick on the command line which I guess would be "convert -define dds:compression=dxt3 testDDS.png testCLI.dds" - Danack

1 Answers

0
votes

From the debugging above the issue is that your version of ImageMagick doesn't support writing DXT3 compressed DDS files.

The options to solve this problem are:

  1. Use a different compression format - DXT5 might be okay, but it's not exactly the same as DXT3.

  2. Upgrade to a newer version of ImageMagick and Imagick that support writing in DXT3 format.