Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request DDSImagePlugin #252

Closed
Metallicow opened this issue Jun 17, 2013 · 18 comments
Closed

Request DDSImagePlugin #252

Metallicow opened this issue Jun 17, 2013 · 18 comments
Milestone

Comments

@Metallicow
Copy link
Contributor

I would like to request the .dds(direct draw surface) format be decoded and added as an image plugin. I guess this is the right place for requests...?

I found this as a start. It doesn't do all dxt formats but some basic ones.
http://nullege.com/codes/show/src%40p%40i%40pilgrim-HEAD%40pilgrim%40codecs%40__init__.py/9/dds.DDS/python

@aclark4life
Copy link
Member

Sure, next step would be to send a pull request if you are able to

@Metallicow
Copy link
Contributor Author

I haven't written anything. Just found some code that works with dxt1 floating around the net.
I'm basically requesting someone with some image decoding skills give it a try. More or less the folks already working on Pillow.
It's kinda a really big format for games. Millions of developers/modders use this format daily.

Niftools / blender plugin
http://niftools.sourceforge.net/wiki/NifTools
or
Pyffi
http://sourceforge.net/projects/pyffi/files/
should/might be of some help with this.

Nvidia tools might help also.
https://developer.nvidia.com/content/dds-utilities-83111271645

@aclark4life
Copy link
Member

No worries, I only suggest you do it because that would increase the chances of it getting done. Otherwise we have to wait for @wiredfool or @d-schmidt to take an interest (which may or may not happen soon, or ever). In any event, thanks for making the request; we now have a record of it, at least

@Metallicow
Copy link
Contributor Author

An interest huh... Haha
A Kickstarter would probably guaranteed generate $5000-10000 if not more for interested developers with the right type of interest.
Millions of people to sell to..., but the salesman, just speaks...
What most people want is an open source interest for the most part. Quality insurance. Per say.
Maybe I will get to it in the next 3 years, maybe not...
Anyway thanks you have a record of it now. :) Apparently got the right hub.

@aclark4life
Copy link
Member

@Metallicow Tee hee hee!

@dessant
Copy link

dessant commented Aug 23, 2015

@aclark4life, could you reopen this feature request?

@aclark4life aclark4life reopened this Aug 23, 2015
@dessant
Copy link

dessant commented Aug 23, 2015

Thanks. ;)

@jleclanche
Copy link
Contributor

That dds code's mine actually, from an experimental PIL fork before Pillow existed.

A dds plugin would be really nice, eg. right now I need to load DXT1 / DXT5 data into Pillow so I have to write my own decoder again =\

@aclark4life
Copy link
Member

@jleclanche Great! So no issue incorporating your dds code into Pillow? I see you are right, pilgrim was born almost a full year before Pillow (2009-11-26 vs 2010-07-31). Interesting.

@jleclanche
Copy link
Contributor

@aclark4life I'm writing an updated version right now which I'm testing against files from .unity3d packing. What license do you want it under?

@aclark4life
Copy link
Member

@jleclanche Great & good question. We use the same license is PIL, in case that helps you decide: https://github.com/python-pillow/Pillow/blob/master/LICENSE

@jleclanche
Copy link
Contributor

@aclark4life ok I'll re-release the decoders as CC0 to make things simpler.

Are you in the #pil channel? I might need some help with writing the plugin.

@aclark4life
Copy link
Member

@jleclanche Yes but you may need @wiredfool or other members of the @python-pillow/pillow-team to weigh in on "real" programming questions. For the @python-pillow/pillow-team , here's some IRC discussion about this issue: http://chat-logs.dcpython.org/day/pil/2016-01-04

@aclark4life aclark4life modified the milestones: 3.2.0, Future Jan 4, 2016
@jleclanche
Copy link
Contributor

https://github.com/HearthSim/python-unitypack/blob/a44c30486246df4aafc0a41adf122b5697e5cdd6/unitypack/dds.py

Here's a dxt1 decoder, licensed CC0. It's pretty slow and will need to be rewritten in C but it's usable.
dxt3 / dxt5 are very straightforward to do from there (I'll be doing them soon-ish if no one else does)

DDS is a container format for s3tc and all the defines are in that file. This is a very old loader for dds (please don't use it), which should give an idea of how to write one.

I won't be filing a PR or anything, unfortunately I don't have time for that; I licensed it so that anyone may use it without having to worry about the license itself :)

By the way in that old project I also have an ftex (IW2 format) decoder lying around.. wouldn't mind making that CC0 as well if someone wants to push it to pillow.
https://github.com/jleclanche/pilgrim/blob/master/pilgrim/codecs/ftex.py

@jleclanche
Copy link
Contributor

@jleclanche
Copy link
Contributor

OK this is actually crazy. I try to write a simple read-only DDS plugin, looks like the API has changed since PIL - fair enough.

I spend four hours trying to figure out the API. I still haven't figured it out as I write this. And none of this is properly documented.

I'm in DDSImageFile.load() and keep getting the very helpful _imaging.c:208: bad argument to internal function when trying to save my image as a png. It looks like this stems from a check on self.im. Can't tell exactly what's wrong with it because every single image plugin is written differently and half of them don't even work. I tried referencing the GbrImagePlugin which was one of the simpler ones but it turns out it uses functions which don't even exist anymore.
So I look at IcnsImagePlugin and it creates an image through self.icns.getimage, which creates it through channels.get(...).copy(), which creates it through dataforsize), which creates it from a bunch of custom readers argh.
Jpeg2KImagePlugin does it with a custom decoder. Of course none of these are listed anywhere I can find, I have to dig in decode.c and figure them out manually.
It would look like the proper way to implement this is to write the dxt* decoder separate, but I don't want to fork Pillow just to be able to read a custom image format, that completely defeats the point.

Please please find some time to work on proper documentation on how to write an image plugin for a custom format and to clean up the image plugins.

@aclark4life
Copy link
Member

@jleclanche I doubt much has changed since PIL, but if it has: you don't need to fork Pillow to fix it you can just fix it (send a PR). Rather than folks maintaining separate forks, we maintain one then release results to PyPI.

@jleclanche
Copy link
Contributor

@aclark4life I fixed it eventually with @wiredfool's help. I'll send a PR.

Honestly there really needs to be a new plugin API, this was very painful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants