0

Env:

python - 3.6.6
Wand - 0.5.7

Code example:

Part of this file

from wand import image

with image.Image(filename='example_32_on_32_px.png') as img:
    img.compression = 'dxt3'
    img.save(filename='output.dds')

It will produce output.dds which contains 5 mipmaps (16px, 8px, 4px, 2px, 1px).

I found CLI example for ImageMagic how to disable creation of mipmaps for output dds files -> this answer
But I need to do same using python and Wand.

Question:

How to prevent / avoid / disable / delete mipmaps in output file using Wand library and python.

Community
  • 1
  • 1
Yuriy Leonov
  • 536
  • 1
  • 9
  • 33

2 Answers2

2

You would use Image.options dict to set the property.

from wand.image import Image

with Image(filename='example_32_on_32_px.png') as img:
    img.options['dds:mipmaps'] = '0'
    img.compression = 'dxt3'
    img.save(filename='output.dds')
emcconville
  • 23,800
  • 4
  • 50
  • 66
0

Based on ImageMagick/ImageMagick/blob/master/coders/dds.c I found following: option=GetImageOption(image_info,"dds:mipmaps");

So solution of my quiestion was quite simple:

from wand import image

with image.Image(filename='example_32_on_32_px.png') as img:
    img.compression = 'dxt3'
    image.library.MagickSetOption(img.wand, b'dds:mipmaps', b'0')
    img.save(filename='output.dds')

If set b'1' instead of b'0' output file will contain only 1 mipmap (16px).

Yuriy Leonov
  • 536
  • 1
  • 9
  • 33