kapa76 / thumbnailator

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

Writing resized image issue on tomcat #37

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Start Tomcat and Read source file at %tomcat%/bin/test_image.jpg
2. Read source image and Create resized image by 
Thumbnails.of("test_image.jpg").size(width, height).toFile("test_target.jpg");
3. Console print out following error message and target image created 0 byte.

What is the expected output? What do you see instead?
2012-05-22 10:21:36,328 ERROR [http-8080-3] taglibs.ImageTag  
(ImageTag.java:223)     - java.io.IOException: Could not open output file.
java.io.IOException: Could not open output file.
    at net.coobird.thumbnailator.tasks.io.FileImageSink.write(Unknown Source)
    at net.coobird.thumbnailator.tasks.SourceSinkThumbnailTask.write(Unknown Source)
    at net.coobird.thumbnailator.Thumbnailator.createThumbnail(Unknown Source)
    at net.coobird.thumbnailator.Thumbnails$Builder.toFile(Unknown Source)

What version of the product are you using? On what operating system? Which
version of Java (Sun/Oracle? OpenJDK?) ?
Thumbnailator 0.4.2
Windows XP
JDK 1.6 (Oracle)

Please provide any additional information below.

I tested this code with junit test module. But result of test was success. See 
following code 

BufferedImage image = Thumbnails.of(srcFile).size(width, 
height).asBufferedImage();
ImageIO.write(image, FilenameUtils.getExtension(targetPath), targetFile);

This code run on tomcat was success.  

I suggest that the message you rewrited in FileImageSink.write() will be change 
by original message. 

Original issue reported on code.google.com by sirius...@gmail.com on 22 May 2012 at 2:18

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry for the late response.

You're quite correct in saying that the exception message "Could not open 
output file." is lacking.

Since this seems to be a case where more information about the original 
exception would be useful in finding out what is causing the problem, I'll open 
another issue to include the original exception message for this type of error.

As to your original problem with writing to a file from Tomcat, I would suspect 
a file permissions issue which is preventing the file from being written to the 
../bin directory.

Since you mention that using the `ImageIO.write` method resulting in the image 
being written, I just want to verify one thing:

Is the filepath for "test_target.jpg" exactly the same as the filepath for 
`targetFile`?

Also, have you had success when you try to use the `Thumbnails.toFile` method 
with the destination specified by the `targetFile` with any success?

Original comment by coobird...@gmail.com on 9 Jun 2012 at 6:33

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi, I read your comment today. 

--------------------------------------------
Is the filepath for "test_target.jpg" exactly the same as the filepath for 
`targetFile`?

Yes, but Thumbails.toFile method throws exception.
---------------------------------------------

I think permission issue is not a cause of exception. Result of file creation 
and writing operation on same directory "%tomcat%\bin" is successful.

Original comment by sirius...@gmail.com on 3 Jul 2012 at 7:22

GoogleCodeExporter commented 9 years ago
I have been facing the same problem. Any solution?

Original comment by mighty...@gmail.com on 2 Aug 2012 at 11:14

GoogleCodeExporter commented 9 years ago
Hi,
I noticed, that if the image already exists and I am overwriting to it, then I 
dont get error..

File thumbnailFile = new File(thumbnailPath);

Thumbnails.of(thumbnailFile)
    .size(160, 160)
    .toFile(thumbnailFile);

Original comment by mighty...@gmail.com on 2 Aug 2012 at 11:27

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi,
I noticed, that if the image already exists and I am overwriting to it, then I 
dont get error..

File thumbnailFile = new File(thumbnailPath+fileName);

         Thumbnails.of(thumbnailFile)
    .size(160, 160)
    .toFile(thumbnailFile);

if thumbnailFile is a non existent file, it doesnt work. 
if thumbnailFile  is already an image file, it is converted to the thumbnail.

Original comment by mighty...@gmail.com on 2 Aug 2012 at 11:29

GoogleCodeExporter commented 9 years ago
Hi mightyrsm,

Sorry for the delay in the reply.

> if thumbnailFile is a non existent file, it doesnt work. 

Could this just mean that the source image doesn't exist, so the file cannot be 
opened to create the thumbnail?

Is it possible to get a stacktrace which is given when this problem occurs?

Original comment by coobird...@gmail.com on 2 Sep 2012 at 4:46

GoogleCodeExporter commented 9 years ago
Hi sirius2kk,

It has been a while, but just as a small update, I'll be changing the way the 
`IOException` is handled in `FileImageSink.write()` so that it isn't rewritten 
by the non-informative `new IOException` in the next release of Thumbnailator.

I'm still not quite sure about the Tomcat issue... I'll have to take a closer 
look to see what's going on.

Original comment by coobird...@gmail.com on 2 Sep 2012 at 4:56

GoogleCodeExporter commented 9 years ago

Original comment by coobird...@gmail.com on 8 Oct 2012 at 5:27

GoogleCodeExporter commented 9 years ago

Original comment by coobird...@gmail.com on 27 Dec 2012 at 4:06

GoogleCodeExporter commented 9 years ago
A change has been made in Thumbnailator 0.4.3 to give a more detailed message 
when an exception is thrown from `FileImageSink.write()`.

Original comment by coobird...@gmail.com on 10 Feb 2013 at 3:51