loadImage from URL and without suffix may not load image correctly. #3442

Closed
tillnagel opened this Issue Jun 29, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@tillnagel

Loading images from a URL (always containing a dot e.g. "processing.org") where the image does not have a suffix (e.g. ".png") results in the image not being loaded: "Could not find a method to load".
Providing "unknown" as second parameter works - e.g. loadImage("processing.org/myImage", "unknown") but now the potential transparency is not handled anymore. Now, when a) I don't know the image suffix, yet b) expect some images to be transparent, there is a problem.

One Solution might be to include "unknown" to the suffixes to check for alpha.

if (extension.equals("gif") || extension.equals("png")) {

Longer explanation
A bit convulated, but I try: When loading an image without specifying the extension(suffix) as second param, Processing tries to guess it from the file name, i.e. loadImage("myImage.png") results in correctly guessing and loading a png. When the file name does not have an extension (e.g. "myImage") one has to specify the suffix manually, i.e. loadImage("myImage", "png") works too.

Now, when one does not know which format the file is, and when trying to load the image from a URL, it tries to find the suffix via searching for the last dot in the filename.

    String filename = "http://openmapsurfer.uni-hd.de/tiles/roads/x=2&y=2&z=2";
    PImage img = loadImage(filename);

Sometimes, web map services provide tiles under URLs without an explicit suffix. Yet, while providing "unknown" as second param loads the image, it does not check for transparency anymore (only for "gif", and "png" extensions).

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Jul 3, 2015

Member

Just pass a legitimate extension as the second parameter to loadImage(). That's what it's there for, and is already an edge case that we support. The idea that you don't know the type is an edge case of an edge case, which is too narrow a use case to further muck up the code.

Member

benfry commented Jul 3, 2015

Just pass a legitimate extension as the second parameter to loadImage(). That's what it's there for, and is already an edge case that we support. The idea that you don't know the type is an edge case of an edge case, which is too narrow a use case to further muck up the code.

@benfry benfry closed this Jul 3, 2015

@benfry benfry added the wontfix label Jul 3, 2015

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Jul 14, 2015

Member

On closer look, doing the "unknown" check makes sense, so we'll do that for a11.

Member

benfry commented Jul 14, 2015

On closer look, doing the "unknown" check makes sense, so we'll do that for a11.

@benfry benfry reopened this Jul 14, 2015

@benfry benfry removed the wontfix label Jul 14, 2015

@benfry benfry closed this Jul 14, 2015

benfry added a commit that referenced this issue Jul 14, 2015

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