Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension is always added to JPG files #18

Closed
GoogleCodeExporter opened this issue Jul 25, 2015 · 4 comments
Closed

Extension is always added to JPG files #18

GoogleCodeExporter opened this issue Jul 25, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

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
Copy link
Author

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

  • Changed state: Fixed

@Nithyananadakamath
Copy link

Wanted to know If we can store the files by converting the filenames to uppercase using thumbnailator. Please let me know if we have any option to do so.. Thanks

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

No branches or pull requests

2 participants