rkalla / exiftool

Enhanced Java Integration for Phil Harvey's ExifTool.
Apache License 2.0
88 stars 57 forks source link

checkFeatureSupport version comparison #23

Open douglove opened 8 years ago

douglove commented 8 years ago

I am using version 10.01 of exiftool. I constructed the ExifTool with Feature.STAY_OPEN. The version compare section of the checkFeatureSupport method uses a string compare and it returns false for supported. Please change the versions to double or float for the comparison.

Existing code if (ver != null && ver.compareTo(feature.version) >= 0) { supported = Boolean.TRUE; log("\t\tFound ExifTool version %s, feature %s is SUPPORTED.", ver, feature); } else { supported = Boolean.FALSE; log("\t\tFound ExifTool version %s, feature %s is NOT SUPPORTED.", ver, feature); }

My solution if(ver != null){ double verDouble = Double.parseDouble(ver); double featureVerDouble = Double.parseDouble(feature.version);

            if(verDouble >= featureVerDouble){
                supported = Boolean.TRUE;
                log("\t\tFound ExifTool version %s, feature %s is SUPPORTED.",
                    ver, feature);
            }else {
                supported = Boolean.FALSE;
                log("\t\tFound ExifTool version %s, feature %s is NOT SUPPORTED.",
                        ver, feature);
            }
        } else {
            supported = Boolean.FALSE;
            log("\t\tFound ExifTool version %s, feature %s is NOT SUPPORTED.",
                    ver, feature);
        }
mattburns commented 8 years ago

Parsing the version as a double is incorrect because doubles 8.4 > 8.36 which is not true for version numbers.

I suggest wrapping the strings in the maven comparable version class DefaultArtifactVersion as described here: http://stackoverflow.com/a/6640972/276093