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

Thumbnail generation fails for certain image types #223

Open
BaolCristian opened this issue Jan 20, 2025 · 0 comments
Open

Thumbnail generation fails for certain image types #223

BaolCristian opened this issue Jan 20, 2025 · 0 comments

Comments

@BaolCristian
Copy link

Description:
I have encountered an issue where the library fails to generate thumbnails for specific types of images. Below are the details:
• Problem: When trying to create thumbnails for certain image files, the process fails and no thumbnail is generated.
• Image Types Affected: PNG (in attach)
• Error Details: no errors, but the file is not saved
• Steps to Reproduce:

                InputStream is = new BufferedInputStream(img.getBinaryStream())
                def result=Thumbnails.of(is).size(width, height).asBufferedImage()
                ByteArrayOutputStream os = new ByteArrayOutputStream();
                ImageIO.write(result, "jpeg", os);
                // Passing: ​(RenderedImage im, String formatName, OutputStream output)
                InputStream fis = new ByteArrayInputStream(os.toByteArray());
                Connection conn = dataSource.getConnection()
                PreparedStatement pst
                if (isMax) pst = conn.prepareStatement("UPDATE FILES SET thumbnail_max = ? WHERE ID = ?")
                else pst = conn.prepareStatement("UPDATE FILES SET thumbnail = ? WHERE ID = ?")
                //= conn.prepareStatement("UPDATE FILES SET thumbnail = ? WHERE ID = ?")
                pst.setBinaryStream(1, fis, fis.available())
                pst.setLong(2, image.id)
                def index = pst.executeUpdate()
                pst.close()
                conn.close()

Environment:
• Library version: 0.4.20
• Operating System: MAC OS X /LINUX
• Programming Language and Version: GRAILS 4

Image

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

No branches or pull requests

1 participant