Opened 17 years ago

Last modified 11 years ago

#1576 closed defect

Certain images with 1-bit-alpha channel lose their transparency — at Version 29

Reported by: anonymous Owned by: team
Priority: minor Milestone: 14.09
Component: Core Version: latest
Keywords: bad icon; mappaint Cc:

Description (last modified by xeen)

With 4938/josm applied, images with none or full alpha transparency should work fine. Certain images (e.g. ./images/styles/standard/accommodation.png optimized with optipng -o7) are rendered opaque with a white background instead of transparent.

Change History (36)

comment:1 by anonymous, 17 years ago

Resolution: wontfix
Status: newclosed

They are not defect. They have been changed to no longer so omnipresent. If you have special problems with individual icons, name these problems directly and reopen the report.

comment:2 by anonymous, 17 years ago

Resolution: wontfix
Status: closedreopened

Ok, but i think they looks now terrible. For example the fuel sign have a white frayed border and if the background is black you can't see them very well.

comment:3 by anonymous, 17 years ago

Owner: changed from framm to anonymous
Status: reopenednew

comment:4 by anonymous, 17 years ago

Owner: changed from anonymous to ulfl

by anonymous, 17 years ago

Attachment: Image1.png added

Some of the bad icons

comment:5 by anonymous, 17 years ago

Priority: majorcritical

I'm 1/3 through the preset menu. Shall I continue to test every preset for the used icon and then look for icons that have no preset? Or do you see the problem and revert or fix the change that caused it?

comment:6 by anonymous, 17 years ago

Owner: changed from ulfl to stoecker
Priority: criticalminor
Summary: Images with white backgrounds are defectImages without alpha channel should not get a transparent background

The change has been reverted to have a hotfix. Neverthelesse the reason is not yet fixed.

BTW: This is in no way a criticial bug. Even if it is major would be subject to discussion.

Error cause: When a PNG image has no alpha channel, JOSM takes the background as alpha channel and makes it transparent. The image optimization removed empty alpha channels from the icons thus triggering that bug in JOSM.

in reply to:  description comment:7 by carolus, 17 years ago

Priority: minormajor
Version: latest

Replying to anonymous:

In the latest Version of JOSM all images with white background (telephon/toilets) are defect. (I think white is now transparent)

Both in JOSM 1043 and JOSM 1042 I see that nodes that are assigned amenity | toilets are not visible in the normal mode. Only in wireframe mode these nodes can be seen in the map window. I just entered a toilet once more where I knew I already entered one last week. Switching to wireframe mode I saw there already was a toilet node. So to save OSM from dublicate nodes, I think the priority should be increased.

by carolus, 17 years ago

Attachment: 01_toilet not visible.png added

Series of screen shots where we see that a toilet node is only visible in wire frame node.

by carolus, 17 years ago

Series of screen shots where we see that a toilet node is only visible in wire frame node.

by carolus, 17 years ago

Series of screen shots where we see that a toilet node is only visible in wire frame node.

comment:8 by Hasienda, 17 years ago

Keywords: bad icon mappaint added

another attempt to fix this by providing the same icons black on white without alpha channel found in ticket duplicate #1692

however, this is really annoying, to me too

Q.: I it really a problem to get hands on not-too-much optimized icons with alpha channel? I could make them from the bad ones with The GIMP on the fly ... (please ask hoff dot st at web dot de)

comment:9 by stoecker, 17 years ago

Owner: changed from stoecker to framm

comment:10 by bastiK, 16 years ago

Owner: changed from framm to anonymous
Status: newneedinfo

Apparently this is fixed.

Some images are still without alpha channel, e.g. /transport/taxi.png, /misc/landmark/tower.png

However they are displayed correctly on the map.

Maybe the issue is still present for an OS other than Linux. Could someone please check on Windows?

comment:11 by bastiK, 16 years ago

Owner: changed from anonymous to team
Status: needinfonew

comment:12 by stoecker, 16 years ago

I think it depends on Java version. We didn't change anything regarding image display.

comment:13 by bastiK, 16 years ago

42 of 523 images in
styles/standard have no Alpha channel:

./leisure/garden.png
./leisure/nature_reserve.png
./sport/bicycle.png
./sport/chess.png
./sport/centre.png
./sport/riding.png
./hunting_stand.png
./rendering/quarry2.png
./rendering/beach.png
./rendering/quarry.png
./nautical/lock_gate.png
./nautical/marina.png
./nautical/anchor.png
./sightseeing/archaeological.png
./vehicle/cattle_grid.png
./vehicle/motorbike.png
./vehicle/gate.png
./vehicle/car_sharing.png
./vehicle/toll_booth.png
./service/administration/court_of_law.png
./service/emergency_access_point.png
./health/eye_specialist.png
./historic/boundary_stone.png
./religion/muslim.png
./religion/hinduism.png
./religion/jainism.png
./transport/airport/terminal.png
./transport/airport/helipad.png
./transport/turntable.png
./transport/taxi.png
./transport/car.png
./money/bank/vr-bank.png
./misc/information/guidepost.png
./misc/landmark/power.png
./misc/landmark/power/hydro.png
./misc/landmark/survey_point.png
./misc/landmark/water_tower.png
./misc/landmark/tower.png
./misc/landmark/beacon.png
./education.png
./accommodation/camping.png
./accommodation/guest_house.png

Would it help to update them?

comment:14 by Cobra, 14 years ago

Resolution: fixed
Status: newclosed

Some of these images are looking rather ugly with the plain white background (imho), but working.

comment:15 by stoecker, 14 years ago

Resolution: fixed
Status: closedreopened

comment:16 by stoecker, 14 years ago

Status: reopenednew

I don't think this is fixed. We did not change a single bit of code for this. It can be it is a Java issue. If so, we need at least to find out and document when Java fixed it. Otherwise this issue still exists.

The included icons have always been adapted properly. Issue was always when optipng or pngcrush has been run to reduce icons size.

comment:17 by xeen, 14 years ago

It isn’t fixed. If you optimize ./images/styles/standard/accommodation.png it will still get a transparent background. This may be fixed by using ImageIO.read instead of Toolkit.getDefaultToolkit().createImage in ImageProvider. While ImageIO works for images w/ or w/o alpha channel it does not work for images with only transparency (i.e. 1 bit alpha channel).

If you want to try it out yourself, the following three images should contain all cases:

  • ./images/styles/standard/accommodation.png; image w/o alpha if optimized (use with node; tourism=hotel)
  • ./images/styles/standard/sport/soccer.png; image w/ alpha (use with node; sport=soccer)
  • ./images/presets/soccer.png; image with transparency (1 bit alpha) (see it in top layer presets menu)

comment:18 by xeen, 14 years ago

hm… the 1 bit alpha bug seems to be present with createImage as well… so in other words: switching to ImageIO would fix some of the PNG alpha bugs…

comment:19 by stoecker, 14 years ago

Maybe we also get rid of these spurious error messages in PNG code which appear sometimes?

comment:20 by xeen, 14 years ago

I’m not sure which messages you are referring to? Anyway, I’ll attach the wip-patch shortly so you can try if it fixes those errors. It only changes how local images are loaded, but applying it to the other cases is trivial.

Given the large amount of 1-bit-alpha images, I’m not sure switching will be of any help. We still can’t run optipng on these images and I haven’t measured how large the impact would be if only the non-1-bit-alpha ones are optimized.

by xeen, 14 years ago

Attachment: use_imgio.patch added

uses ImageIO for reading local files

by xeen, 14 years ago

Attachment: 1-bit-alpha.txt added

List of 1-bit-alpha images (+command which finds them)

comment:21 by stoecker, 14 years ago

See #2904.

comment:22 by xeen, 14 years ago

I measured the time it takes to init the presets menu. The difference is negligible, so switching won’t regress startup time.

imageio   toolkit
1512 ms   1299 ms
1535 ms   1302 ms
1288 ms   1528 ms
1676 ms   1265 ms
1488 ms   1343 ms
1494 ms   1435 ms

1499 ms   1362 ms   AVG        
 114 ms     91 ms   STDDEV

Next up: space savings w/ non-1-bit-alpha PNGs optimized

comment:23 by xeen, 14 years ago

7358312 josm-normal.jar
7338405 josm-opti-non1bitalpha.jar
7334603 josm-all-opti.jar

so 19907 bytes (~19 KiB) saved. Could save another 3802 bytes (~4 KiB) if all images could be read properly.

Script used:

#!/bin/zsh
for x in images/**/*.png; do
  identify -quiet -verbose "${x}" | grep "alpha: 1-bit" || optipng -o7 "${x}"
done
Last edited 14 years ago by xeen (previous) (diff)

comment:24 by xeen, 14 years ago

I suggest using ImageIO because it fixes the originally reported issue. The 1-bit-alpha bug exists in both implementations, so no change here. Speed regression is negligible. There is a remote chance this might also fix #2904 and similar.

While the space savings are minimal, I can now provide a working shell script that compresses the images automatically without causing a transparency bug (hopefully, at least). The savings are now at ~27 KiB, although I have no idea why the new method saves more than optimizing all images.

Are there any objections? If not, shall I add the script to SVN?

by xeen, 14 years ago

Attachment: optimize-images added

Script that optimizes all PNGs in images/ without causing an alpha transparency bug

comment:25 by stoecker, 14 years ago

Are there any objections?

No.

If not, shall I add the script to SVN?

I think so.

comment:26 by xeen, 14 years ago

In 4938/josm:

use ImageIO instead of Toolkit’s createImage. PNGs without alpha channel should not get a transparent background anymore. See #1576

comment:27 by xeen, 14 years ago

In 4939/josm:

add shell script that compresses all PNGs

Requires ImageMagick and optipng to be installed and available in $PATH.
Works around bug which causes PNGs with 1-bit-alpha-channels to have an
opaque background (see #1576)

comment:28 by xeen, 14 years ago

In 4940/josm:

Optimize images. Please report if images changed (esp. if the background changed from color to transparent or vice versa). See #1576

comment:29 by xeen, 14 years ago

Description: modified (diff)
Priority: majorminor
Summary: Images without alpha channel should not get a transparent backgroundCertain images with 1-bit-alpha channel lose their transparency
Note: See TracTickets for help on using tickets.