#20341 closed enhancement (fixed)
[Patch] Support more image formats
Reported by: | Bjoeni | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 21.02 |
Component: | Core image mapping | Version: | |
Keywords: | java11 | Cc: | stoecker |
Description
I think JOSM should support more image formats than just JPEG.
The attached patch determines the image file formats that are supported by the client system / the java version and the metadata library. It allows opening them through javax.ImageIO
.
E.g. on Java 8 JOSM then allows opening *.bmp,*.gif,*.jpg,*.jpeg,*.png
, on Java 11 also *.tif,*.tiff
. I'm unsure if there are any other formats available / unavailable in other versions/systems but the script should be able to deal with that accordingly.
I had to remove some compiler exclusions in the build.xml
of the metadata-extractor library (for the FileTypeDetector
) which results in a ~120kb larger dist (.jar). I can try to strip that further down, but I would have to implement each format manually which could result in further problems and would also not be flexible in case future Java versions (or plugins) support more image formats. So I think it makes sense to rely on the existing library at the cost of a few kb.
--
Also attached is a patch for the plugin photo_geotagging which enables writing metadata to both JPEG and TIFF files and warns in case other unsupported formats are present.
Attachments (5)
Change History (34)
by , 4 years ago
Attachment: | 20341-core.diff added |
---|
by , 4 years ago
Attachment: | 20341-photo_geotagging.diff added |
---|
comment:1 by , 4 years ago
comment:2 by , 4 years ago
Keywords: | java11 added |
---|
comment:3 by , 4 years ago
It's not about which formats are supported (these are a couple lines of code), it's the metadata library that has a format determination (based on the first bytes of the file, not the extension).
I'll see what I can actually strip away from that library, it won't be bulletproof but should still work in most cases.
comment:4 by , 4 years ago
Ok so the minimum I'm getting would be ~50kb more, that is by implementing all the formats mentioned above individually. Would that be fine?
Otherwise it's not possible to read the metadata in any format other than JPEG and TIFF (which includes the date taken). I could possibly use the last modified date instead but that's not always gonna be the same.
Or I could only implement it for some formats. The additional cost would be:
bmp: 18 kb gif: 13 kb png: 18 kb
What do you think? Worth 50kb or not?
comment:5 by , 4 years ago
Actually, I think I could get rid of BMP metadata support since it doesn't contain the date taken anyways. And while GIFs can technically contain XMP data (and therefore exif data) I think it's neither commonly used nor does it really make much sense.
So we'd be down to an additional 18kb for PNGs, that should be fine I guess? For the other formats I'll just fall back to the lastModifiedDate.
by , 4 years ago
Attachment: | 20341-core-V2.diff added |
---|
comment:7 by , 4 years ago
Well I'm using PNG for this purpose sometimes, because it supports alpha channels, lossless compression (somewhat better than TIFF) and is compatible with web browsers (unlike TIFF again).
Can't speak for others though.
follow-up: 11 comment:10 by , 4 years ago
Thanks!
Support metadata from more image formats
Just for the changelog: It's not just supporting the metadata but supporting the format, because before the patch JOSM was unable to open these formats completely :)
The photo_geotagging plugin should also be updated before the next stable as it will crash when the user attempts to write metadata to a non-JPEG image (see the second attachment above).
Could you please give me access to the plugin repo? Then I can try to commit it myself.
follow-up: 12 comment:11 by , 4 years ago
Cc: | added |
---|
Replying to Bjoeni:
Could you please give me access to the plugin repo? Then I can try to commit it myself.
@Dirk is it possible to give an OSM svn account to Bjoeni?
comment:12 by , 4 years ago
follow-up: 14 comment:13 by , 4 years ago
Can you please insert a name in the Trac account settings
done!
follow-up: 17 comment:14 by , 4 years ago
Replying to Bjoeni:
Can you please insert a name in the Trac account settings
done!
You should have access to plugin-svn now.
follow-up: 18 comment:15 by , 4 years ago
comment:17 by , 4 years ago
comment:18 by , 4 years ago
Replying to skyper:
Replying to Don-vip:
In 17548/josm:
Jenkins reports two PMDs and some lower warnings.
I'll have a look
by , 4 years ago
Attachment: | 20341-core-V3.diff added |
---|
fix Jenkins warnings and NPE caused by malformed images
comment:19 by , 4 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
I'm gonna reopen this ticket since I guess it makes sense to fix the potential NPE before the next stable
comment:20 by , 4 years ago
toUnmodifiableList has been introduced in Java 10, we still need Java 8 compatibility.
follow-up: 22 comment:21 by , 4 years ago
Damned, I always forget that. One second, I'll change it.
Let's hope that the number of Java 8 users actually goes down in the foreseeable future...
by , 4 years ago
Attachment: | 20341-core-V4.diff added |
---|
comment:22 by , 4 years ago
follow-up: 27 comment:26 by , 4 years ago
comment:27 by , 4 years ago
Replying to stoecker:
I don't consider replacing the
correcttrn() usage by handcoded stuff a fix. This will break a lot of languages! Extracting the single case is ok, but the other one still needs trn()!
The old string was completely broken and was untranslatable on Launchpad. I didn't see any better solution.
I don't think it is worth to be fully dynamic here. Just keep it simple: hardcode
*.bmp,*.gif,*.jpg,*.jpeg,*.png
on Java < 11,*.bmp,*.gif,*.jpg,*.jpeg,*.png,*.tif,*.tiff
on Java >= 11.It's very rare to see new image formats to be shipped in the JDK. We can update the list manually if it ever happens. 120k for just this functionality is too much.