Bug 26848 - PNG images using JIMI instead JAI
Summary: PNG images using JIMI instead JAI
Status: CLOSED WONTFIX
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: images (show other bugs)
Version: all
Hardware: All All
: P3 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
: 26847 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-02-11 09:54 UTC by joaquin sanchez
Modified: 2012-04-30 00:17 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description joaquin sanchez 2004-02-11 09:54:36 UTC
Trying to create an external graphics using a PNG file does not works if you 
want to use JIMI instead JAI.

Location:

class::org.apache.fop.image.FopImageFactory
method::getGenericImageClassName

You catch an Exception when configuring m_genericImageClassName field. If you 
have configured JIMI in your classpath instead JAI it throws an Error:

java.lang.NoClassDefFoundError: javax/media/jai/PlanarImage
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:141)
	at org.apache.fop.image.FopImageFactory.getGenericImageClassName
(FopImageFactory.java:236)
	at org.apache.fop.image.FopImageFactory.Make(FopImageFactory.java:163)
...
...

In this scenario you cannot use FOP to render a PNG file. To solve this BUG you 
must catch Throwable instead Exception.

A workaround is to set m_genericImageClassName 
to "org.apache.fop.image.JimiImage" via java.lang.reflect package before you 
call FOP.

Bye.

Thanks.
Comment 1 J.Pietschmann 2004-02-12 00:08:03 UTC
*** Bug 26847 has been marked as a duplicate of this bug. ***
Comment 2 joaquin sanchez 2004-02-12 07:46:14 UTC
Solution:

    private static String getGenericImageClassName() {

        if (m_genericImageClassName == null) {
            try {
                Class.forName("org.apache.fop.image.JAIImage");
                m_genericImageClassName = "org.apache.fop.image.JAIImage";
            } catch (Throwable ex) {
                /* on any exception assume Jai is not present and use Jimi 
instead */
                m_genericImageClassName = "org.apache.fop.image.JimiImage";
            }
        }
        return m_genericImageClassName;
    }

Workaround:

    public static String checkFOP() {

        try {
            FopImageFactory.Make(PDFGenerator.class.getResource("blank.png");
            return "png"; 
        } catch (Throwable t) {
            try {
                // trying to set by hand Bug#: 26848 from FOP
                Class clazz = Class.forName
("org.apache.fop.image.FopImageFactory");
                java.lang.reflect.Field field = clazz.getDeclaredField
("m_genericImageClassName");
                field.setAccessible(true);
                field.set(null, "org.apache.fop.image.JimiImage");
                FopImageFactory.Make(PDFGenerator.class.getResource
("blank.png");
                return "png"; 
            } catch (Throwable _t) {
                return "jpeg"; 
            }
        }
    }

Comment 3 Glenn Adams 2012-04-07 04:27:10 UTC
jimi is no longer supported
Comment 4 Glenn Adams 2012-04-30 00:14:41 UTC
batch transition resolved+wontfix to closed+wontfix
Comment 5 Glenn Adams 2012-04-30 00:17:13 UTC
batch transition resolved+wontfix to closed+wontfix; if you believe this remains a bug and can demonstrate it with appropriate input FO file and output PDF file (as applicable), then you may reopen