ghosta3 / thumbnailator

Automatically exported from code.google.com/p/thumbnailator
Other
0 stars 0 forks source link

Extension is always added to JPG files #18

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Have the following code wrapped in a web service:

Thumbnails.of("C:\\images\\PSC001.JPG")
          .size(160, 160)
          .toFile("C:\\images\\thumbs\\PSC001.JPG");

However, the output (for jpg and jpeg extensions only) is 

C:\images\thumbs\PSC001.JPG.JPEG

if I do .outputFormat("jpg") I get

C:\images\thumbs\PSC001.JPG.jpg

For some reason it always tags on an extra extension.  Don't know if this is 
supposed to happen but could you let me know?

Thumbnailator-0.3.8.jar
jdk1.6.0_20 
NetBeans IDE 7.0 (Build 201104080000)

Thanks
Chris

Great product, thanks

Original issue reported on code.google.com by cjnjo...@gmail.com on 8 Aug 2011 at 9:52

GoogleCodeExporter commented 9 years ago
Hi Chris,

Thank you for reporting this issue.

The behavior you've described is definitely not deliberate, and works contrary 
to what would be reasonably expected.

This issue seems to occur when the file extension for the output file is in 
lowercase letters. (e.g. JPG, Jpg, etc)

I'll have to take a closer look into what kind of use cases exhibits this 
issue, and then I'll address the issue and release a new version of 
Thumbnailator.

I can't make any promises about when I can fix the problem, but if not this 
weekend, I should be able to by the end of this month.

Once again, thank you for taking the time to write a detailed report on this 
issue.

Chris

Original comment by coobird...@gmail.com on 10 Aug 2011 at 3:55

GoogleCodeExporter commented 9 years ago
Hi, thanks for the quick response, look forward to the next release but no
time pressure from my end.

Original comment by cjnjo...@gmail.com on 10 Aug 2011 at 7:05

GoogleCodeExporter commented 9 years ago
This issue has been addressed in Thumbnailator 0.3.9.

-----

This defect was causing extraneous file extensions to be appended to the end of 
thumbnail filenames when the file extension of the specified destination was 
not in lowercase.

For example, the following code did not cause an extraneous file extension to 
be added, as the destination file name specifies the extension with lowercase 
letters:

  Thumbnails.of("path/to/image.jpg")
    .size(100, 100)
    .toFile("path/to/thumbnail.jpg");
  // -> The thumbnail is written to "path/to/thumbnail.jpg"

The following, however, will have an extraneous "jpg" appended to the end of 
the file name, as the file extension of the destination is a uppercase "JPG":

  Thumbnails.of("path/to/image.jpg")
    .size(100, 100)
    .toFile("path/to/thumbnail.JPG");
  // -> The thumbnail is written to "path/to/thumbnail.JPG.jpg"

Furthermore, specifying the output format via the `outputFormat` method could 
have lead to even stranger behavior when the format was not specified in 
lowercase:

  Thumbnails.of("path/to/image.jpg")
    .size(100, 100)
    .outputFormat("JPG")
    .toFile("path/to/thumbnail.JPG");
  // -> The thumbnail is written to "path/to/thumbnail.JPG.JPG"

These were serious violations of the principle of least surprise, and 
furthermore, extremely difficult to work around.

-----

Now, the destination file name is considered "correct", so unless there is a 
incorrect (extension not suitable for the format specified in the 
`outputFormat` method) or missing extension in which case the default file 
extension will be appended to the file name.

Please refer to the following examples to see how Thumbnailator 0.3.9 handles 
file extensions:

  Thumbnails.of("path/to/image.jpg")
    .size(100, 100)
    .toFile("path/to/thumbnail.JPEG");
  // -> The thumbnail is written to "path/to/thumbnail.JPEG"

  Thumbnails.of("path/to/image.jpg")
    .size(100, 100)
    .outputFormat("jpg")
    .toFile("path/to/thumbnail.JPEG");
  // -> The thumbnail is written to "path/to/thumbnail.JPEG"

  Thumbnails.of("path/to/image.jpg")
    .size(100, 100)
    .outputFormat("JPEG")
    .toFile("path/to/thumbnail.jpg");
  // -> The thumbnail is written to "path/to/thumbnail.jpg"

Original comment by coobird...@gmail.com on 13 Aug 2011 at 12:21