Re: Problem with scaling png image file in svg
Jay Chiu wrote: Chris, I have successfylly solved the problem. I think it is a fop bug. It does look that way. I have just changed 2 lines of PDFGraphics2D.java: line 289: and line 296 FROM: Dimension size = new Dimension(imageInfo.width * ratio, imageInfo.height * 3); and g.fillRect(0, 0, imageInfo.width * ratio, imageInfo.height * 3); TO: Dimension size = new Dimension(imageInfo.width * ratio, imageInfo.height); and g.fillRect(0, 0, imageInfo.width * ratio, imageInfo.height); I think it is not necessary to enlarge the image 3 times. yes that does seem odd. I wonder why the image is enlarged by multiple of 3. That does seem like a bug. Another thing I found out is that JIMI support is not required for png file in svg. So probably fop should be able suport png file natively. I am not sure what you mean by this statement. Can you elaborate? Please have add my change change into your next release of FOP. Thanks for your persistence in solving this problem Jay. Chris - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with scaling png image file in svg
It's Batik's job to load images within SVG files. Batik has its own PNG codec built in. FOP currently can't use it. Batik and FOP use different ways to load images. On 16.02.2004 11:15:24 Chris Bowditch wrote: Another thing I found out is that JIMI support is not required for png file in svg. So probably fop should be able suport png file natively. I am not sure what you mean by this statement. Can you elaborate? Jeremias Maerki - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with scaling png image file in svg
Jeremias Maerki wrote: It's Batik's job to load images within SVG files. Batik has its own PNG codec built in. FOP currently can't use it. Batik and FOP use different ways to load images. Thanks Jeremias - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: Problem with scaling png image file in svg
Chris, I have successfylly solved the problem. I think it is a fop bug. I have just changed 2 lines of PDFGraphics2D.java: line 289: and line 296 FROM: Dimension size = new Dimension(imageInfo.width * ratio, imageInfo.height * 3); and g.fillRect(0, 0, imageInfo.width * ratio, imageInfo.height * 3); TO: Dimension size = new Dimension(imageInfo.width * ratio, imageInfo.height); and g.fillRect(0, 0, imageInfo.width * ratio, imageInfo.height); I think it is not necessary to enlarge the image 3 times. After the change, the PDF image object forpng in svg is almost the same as that directly in pdf file: external png image 6 0 obj /Type /XObject /Subtype /Image /Name /Im1 /Length 26341 /Width 500 /Height 400 /BitsPerComponent 8 /ColorSpace /DeviceRGB /Filter [ /ASCII85Decode /FlateDecode ] svg png image 11 0 obj /Type /XObject /Subtype /Image /Name /Im2 /Length 26341 /Width 500 /Height 400 /BitsPerComponent 8 /ColorSpace /DeviceRGB /Mask [255 255 255 255 255 255] /Filter [ /ASCII85Decode /FlateDecode ] Another thing I found out is that JIMI support is not required for png file in svg. So probably fop should be able suport png file natively. Please have add my change change into your next release of FOP. Thanks a lot. Jay Get your own 800 number Voicemail, fax, email, and a lot more http://www.ureach.com/reg/tag On Thu, 12 Feb 2004, Jay Chiu ([EMAIL PROTECTED]) wrote: Thanks Chris, I feel the difference for external png file and SVG are, Fop uses JIMI to handle the external png file, while Batik loads the png image into BufferedImageCachableRed object and fop PDFGraphics2D class handles png image in SVG. The org.apache.fop.svg.PDFGraphics2D class is equivalent to org.apache.fop.image.JimiImage for fop external png file. Both external png file and png in SVG are processed by PDFXObject.output method in the end. With the same png file of size 500x400 and size setting 250x200 in fo, the PDFXObject.output method outputs object info to pdf are, for png in SVG: 6 0 obj /Type /XObject /Subtype /Image /Name /Im1 /Length 49745 /Width 1500 /Height 1200 /BitsPerComponent 8 /ColorSpace /DeviceRGB /Mask [255 255 255 255 255 255] /Filter [ /ASCII85Decode /FlateDecode ] and for external png is - 6 0 obj /Type /XObject /Subtype /Image /Name /Im1 /Length 26341 /Width 500 /Height /BitsPerComponent 8 /ColorSpace /DeviceRGB /Filter [ /ASCII85Decode /FlateDecode ] --- So the object size is different and the object length is different. Thus the question is how to make the PDFGraphics2D to create the same data as JimiImage. Any help is greatly appreciated. Jay List: fop-user Subject:Re: Problem with scaling png image file in svg From: Chris Bowditch bowditch_chris () hotmail ! com Date: 2004-02-12 9:55:10 Message-ID: 402B4D7E.7060401 () hotmail ! com [Download message RAW] Jay Chiu wrote: Chris and Thomas, Can you please give me some help? Please tell me which files I should change to solve the problem. I have run your sample, and the PNG files referenced by fo:external-graphic are indeed much better quaility than those embedded in SVG using svg:image. I then tried running FOP using -awt option instead of generating a PDF and found that the quality of the PNG files in fo:external-graphic are bad. That is because the AWT renderer probably uses the PDFGraphics2D.drawImage method that you mention. I only saw part of Thomas's response, in which he seems to be implying that the problem is in Batik, but it does seem that there are defficiencies in FOP's image handling algorithms. I believe the images look okay in the PDF Renderer because responsibility for actually rendering the image is passed to acrobat reader. FOP just inserts the image into the PDF. I dont know if theres a way to tell the PDF transcoder to do the same. Perhaps one of the more experienced committers can shed some more light on this matter. Chris Get your own 800 number Voicemail, fax, email, and a lot more http://www.ureach.com/reg/tag On Wed, 11 Feb 2004, Jay Chiu ([EMAIL PROTECTED]) wrote: Chris and Thomas, Can you please give me some help? Please tell me which files I should change to solve the problem. Thanks a lot. Jay List: fop-user Subject:Re: Re: Problem with scaling png image file in svg From: Jay Chiu jaychiu () ureach ! com Date: 2004-02-10 5:13:26 I think changing org.apache.fop.svg.PDFGraphics2D class may solve the image quality issue. Because PDFGraphics2D class hangles the image drawing. Can Fop developer
Re: Re: Problem with scaling png image file in svg
Thanks Chris, I feel the difference for external png file and SVG are, Fop uses JIMI to handle the external png file, while Batik loads the png image into BufferedImageCachableRed object and fop PDFGraphics2D class handles png image in SVG. The org.apache.fop.svg.PDFGraphics2D class is equivalent to org.apache.fop.image.JimiImage for fop external png file. Both external png file and png in SVG are processed by PDFXObject.output method in the end. With the same png file of size 500x400 and size setting 250x200 in fo, the PDFXObject.output method outputs object info to pdf are, for png in SVG: 6 0 obj /Type /XObject /Subtype /Image /Name /Im1 /Length 49745 /Width 1500 /Height 1200 /BitsPerComponent 8 /ColorSpace /DeviceRGB /Mask [255 255 255 255 255 255] /Filter [ /ASCII85Decode /FlateDecode ] and for external png is - 6 0 obj /Type /XObject /Subtype /Image /Name /Im1 /Length 26341 /Width 500 /Height /BitsPerComponent 8 /ColorSpace /DeviceRGB /Filter [ /ASCII85Decode /FlateDecode ] --- So the object size is different and the object length is different. Thus the question is how to make the PDFGraphics2D to create the same data as JimiImage. Any help is greatly appreciated. Jay List: fop-user Subject:Re: Problem with scaling png image file in svg From: Chris Bowditch bowditch_chris () hotmail ! com Date: 2004-02-12 9:55:10 Message-ID: 402B4D7E.7060401 () hotmail ! com [Download message RAW] Jay Chiu wrote: Chris and Thomas, Can you please give me some help? Please tell me which files I should change to solve the problem. I have run your sample, and the PNG files referenced by fo:external-graphic are indeed much better quaility than those embedded in SVG using svg:image. I then tried running FOP using -awt option instead of generating a PDF and found that the quality of the PNG files in fo:external-graphic are bad. That is because the AWT renderer probably uses the PDFGraphics2D.drawImage method that you mention. I only saw part of Thomas's response, in which he seems to be implying that the problem is in Batik, but it does seem that there are defficiencies in FOP's image handling algorithms. I believe the images look okay in the PDF Renderer because responsibility for actually rendering the image is passed to acrobat reader. FOP just inserts the image into the PDF. I dont know if theres a way to tell the PDF transcoder to do the same. Perhaps one of the more experienced committers can shed some more light on this matter. Chris Get your own 800 number Voicemail, fax, email, and a lot more http://www.ureach.com/reg/tag On Wed, 11 Feb 2004, Jay Chiu ([EMAIL PROTECTED]) wrote: Chris and Thomas, Can you please give me some help? Please tell me which files I should change to solve the problem. Thanks a lot. Jay List: fop-user Subject:Re: Re: Problem with scaling png image file in svg From: Jay Chiu jaychiu () ureach ! com Date: 2004-02-10 5:13:26 I think changing org.apache.fop.svg.PDFGraphics2D class may solve the image quality issue. Because PDFGraphics2D class hangles the image drawing. Can Fop developer please give me some help? I tried to debug through fop with batik and find the call stack for handling my png image is as following: (1)org.apache.fop.svg.PDFGraphics2D.drawImage(Image img, int x, int y,ImageObserver observer) (2)org.apache.batik.ext.awt.image.GraphicsUtil.drawImag(Graphics2D g2d, CachableRed cr):152 (3)org.apache.batik.ext.awt.image.GraphicsUtil.drawImag(Graphics2D g2d, CachableRed cr):439 (4)org.apache.batik.gvt.primitivePaint(Graphics2D g2d):92 (5)org.apache.batik.gv.AbstractGraphicsNode.paint(Graphics2D g2d):485 (6)org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(Graphics2D g2d):130 (7)org.apache.batik.gv.AbstractGraphicsNode.paint(Graphics2D g2d):485 (8)org.apache.batik.gvt.ImageNode.paint(Graphics2D g2d):34 org.apache.batik.gv.AbstractGraphicsNode.paint(Graphics2D g2d) From the call stack info, it is clear that PDFGraphics2D handles the actual external image drawing. Can someone change PDFGraphics2d to use the same approach to handle external image file as other image handling code in FOP does? Thanks. Jay On Sat, 07 Feb 2004, Jay Chiu ([EMAIL PROTECTED]) wrote: Thanks Thomas, I guess anyone who includes images in SVG may get the same problem. We are delivering a report tool to client and the client is complaining about the chart quality in pdf. Thus we are in a hurry to solve this isse. If someone has already written some code to solve this issue, please forward me some of your code. If it is not too difficult, can you please give me some hint and tell
Re: Re: Problem with scaling png image file in svg
Chris and Thomas, Can you please give me some help? Please tell me which files I should change to solve the problem. Thanks a lot. Jay List: fop-user Subject:Re: Re: Problem with scaling png image file in svg From: Jay Chiu jaychiu () ureach ! com Date: 2004-02-10 5:13:26 I think changing org.apache.fop.svg.PDFGraphics2D class may solve the image quality issue. Because PDFGraphics2D class hangles the image drawing. Can Fop developer please give me some help? I tried to debug through fop with batik and find the call stack for handling my png image is as following: (1)org.apache.fop.svg.PDFGraphics2D.drawImage(Image img, int x, int y,ImageObserver observer) (2)org.apache.batik.ext.awt.image.GraphicsUtil.drawImag(Graphics2D g2d, CachableRed cr):152 (3)org.apache.batik.ext.awt.image.GraphicsUtil.drawImag(Graphics2D g2d, CachableRed cr):439 (4)org.apache.batik.gvt.primitivePaint(Graphics2D g2d):92 (5)org.apache.batik.gv.AbstractGraphicsNode.paint(Graphics2D g2d):485 (6)org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(Graphics2D g2d):130 (7)org.apache.batik.gv.AbstractGraphicsNode.paint(Graphics2D g2d):485 (8)org.apache.batik.gvt.ImageNode.paint(Graphics2D g2d):34 org.apache.batik.gv.AbstractGraphicsNode.paint(Graphics2D g2d) From the call stack info, it is clear that PDFGraphics2D handles the actual external image drawing. Can someone change PDFGraphics2d to use the same approach to handle external image file as other image handling code in FOP does? Thanks. Jay On Sat, 07 Feb 2004, Jay Chiu ([EMAIL PROTECTED]) wrote: Thanks Thomas, I guess anyone who includes images in SVG may get the same problem. We are delivering a report tool to client and the client is complaining about the chart quality in pdf. Thus we are in a hurry to solve this isse. If someone has already written some code to solve this issue, please forward me some of your code. If it is not too difficult, can you please give me some hint and tell me which file should be changed? I guess probably we may take some fop's code to solve this issue, becuase the subsampling works fine in Fop. Thanks a lot. Jay == Subject: Re: Problem with scaling png image file in svg From: Thomas DeWeese [EMAIL PROTECTED] Date: Fri, 06 Feb 2004 06:25:45 -0500 To: batik-dev@xml.apache.org Jay Chiu wrote: I tried with Batik Squiggle for the png images. If I does not use g transform=scale(xxx), the png image looks good in the GUI, it does get scaled properly. But image with scale() transform attribute losses quality, and the png file generated by Squiggle is in bad quality. The problem is that you are asking to subsample the image too much. The large image is reduced by 5x the small by 10x. Batik does not prefilter for large subsample values so you 'loose' pixels with subsample values this high and the result is aliasing effects. If anyone wants to write/contribute a block average or better a true prefiltered resample operation I'm sure it would be appreciated. I can help with plugging it into Batik in the right spot. I am also sending the email to batik-user mail list. Hope Batik team can also help. Attache please find a svg file , a source png file and generated png file. Thanks a lot. Jay Get your own 800 number Voicemail, fax, email, and a lot more http://www.ureach.com/reg/tag Get your own 800 number Voicemail, fax, email, and a lot more http://www.ureach.com/reg/tag - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with scaling png image file in svg
Jay Chiu wrote: Chris and Thomas, Can you please give me some help? Please tell me which files I should change to solve the problem. I have run your sample, and the PNG files referenced by fo:external-graphic are indeed much better quaility than those embedded in SVG using svg:image. I then tried running FOP using -awt option instead of generating a PDF and found that the quality of the PNG files in fo:external-graphic are bad. That is because the AWT renderer probably uses the PDFGraphics2D.drawImage method that you mention. I only saw part of Thomas's response, in which he seems to be implying that the problem is in Batik, but it does seem that there are defficiencies in FOP's image handling algorithms. I believe the images look okay in the PDF Renderer because responsibility for actually rendering the image is passed to acrobat reader. FOP just inserts the image into the PDF. I dont know if theres a way to tell the PDF transcoder to do the same. Perhaps one of the more experienced committers can shed some more light on this matter. Chris - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: Problem with scaling png image file in svg
I think changing org.apache.fop.svg.PDFGraphics2D class may solve the image quality issue. Because PDFGraphics2D class hangles the image drawing. Can Fop developer please give me some help? I tried to debug through fop with batik and find the call stack for handling my png image is as following: (1)org.apache.fop.svg.PDFGraphics2D.drawImage(Image img, int x, int y,ImageObserver observer) (2)org.apache.batik.ext.awt.image.GraphicsUtil.drawImag(Graphics2D g2d, CachableRed cr):152 (3)org.apache.batik.ext.awt.image.GraphicsUtil.drawImag(Graphics2D g2d, CachableRed cr):439 (4)org.apache.batik.gvt.primitivePaint(Graphics2D g2d):92 (5)org.apache.batik.gv.AbstractGraphicsNode.paint(Graphics2D g2d):485 (6)org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(Graphics2D g2d):130 (7)org.apache.batik.gv.AbstractGraphicsNode.paint(Graphics2D g2d):485 (8)org.apache.batik.gvt.ImageNode.paint(Graphics2D g2d):34 org.apache.batik.gv.AbstractGraphicsNode.paint(Graphics2D g2d) From the call stack info, it is clear that PDFGraphics2D handles the actual external image drawing. Can someone change PDFGraphics2d to use the same approach to handle external image file as other image handling code in FOP does? Thanks. Jay On Sat, 07 Feb 2004, Jay Chiu ([EMAIL PROTECTED]) wrote: Thanks Thomas, I guess anyone who includes images in SVG may get the same problem. We are delivering a report tool to client and the client is complaining about the chart quality in pdf. Thus we are in a hurry to solve this isse. If someone has already written some code to solve this issue, please forward me some of your code. If it is not too difficult, can you please give me some hint and tell me which file should be changed? I guess probably we may take some fop's code to solve this issue, becuase the subsampling works fine in Fop. Thanks a lot. Jay == Subject: Re: Problem with scaling png image file in svg From: Thomas DeWeese [EMAIL PROTECTED] Date: Fri, 06 Feb 2004 06:25:45 -0500 To: batik-dev@xml.apache.org Jay Chiu wrote: I tried with Batik Squiggle for the png images. If I does not use g transform=scale(xxx), the png image looks good in the GUI, it does get scaled properly. But image with scale() transform attribute losses quality, and the png file generated by Squiggle is in bad quality. The problem is that you are asking to subsample the image too much. The large image is reduced by 5x the small by 10x. Batik does not prefilter for large subsample values so you 'loose' pixels with subsample values this high and the result is aliasing effects. If anyone wants to write/contribute a block average or better a true prefiltered resample operation I'm sure it would be appreciated. I can help with plugging it into Batik in the right spot. I am also sending the email to batik-user mail list. Hope Batik team can also help. Attache please find a svg file , a source png file and generated png file. Thanks a lot. Jay Get your own 800 number Voicemail, fax, email, and a lot more http://www.ureach.com/reg/tag Get your own 800 number Voicemail, fax, email, and a lot more http://www.ureach.com/reg/tag - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with scaling png image file in svg
Thanks Thomas, I guess anyone who includes images in SVG may get the same problem. We are delivering a report tool to client and the client is complaining about the chart quality in pdf. Thus we are in a hurry to solve this isse. If someone has already written some code to solve this issue, please forward me some of your code. If it is not too difficult, can you please give me some hint and tell me which file should be changed? I guess probably we may take some fop's code to solve this issue, becuase the subsampling works fine in Fop. Thanks a lot. Jay == Subject: Re: Problem with scaling png image file in svg From: Thomas DeWeese [EMAIL PROTECTED] Date: Fri, 06 Feb 2004 06:25:45 -0500 To: batik-dev@xml.apache.org Jay Chiu wrote: I tried with Batik Squiggle for the png images. If I does not use g transform=scale(xxx), the png image looks good in the GUI, it does get scaled properly. But image with scale() transform attribute losses quality, and the png file generated by Squiggle is in bad quality. The problem is that you are asking to subsample the image too much. The large image is reduced by 5x the small by 10x. Batik does not prefilter for large subsample values so you 'loose' pixels with subsample values this high and the result is aliasing effects. If anyone wants to write/contribute a block average or better a true prefiltered resample operation I'm sure it would be appreciated. I can help with plugging it into Batik in the right spot. I am also sending the email to batik-user mail list. Hope Batik team can also help. Attache please find a svg file , a source png file and generated png file. Thanks a lot. Jay Get your own 800 number Voicemail, fax, email, and a lot more http://www.ureach.com/reg/tag - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with scaling png image file in svg section
Thanks Chris. I tried with Batik Squiggle for the png images. If I does not use g transform=scale(xxx), the png image looks good in the GUI, it does get scaled properly. But image with scale() transform attribute losses quality, and the png file generated by Squiggle is in bad quality. I am also sending the email to batik-user mail list. Hope Batik team can also help. Attache please find a svg file , a source png file and generated png file. Thanks a lot. Jay List: fop-user Subject:Re: Problem with scaling png image file in svg section From: Chris Bowditch bowditch_chris () hotmail ! com Date: 2004-02-05 9:11:43 Message-ID: 402208CF.4010500 () hotmail ! com [Download message RAW] Jay Chiu wrote: I generate fo file with svg section to hold absolute positioned text and images. If the image size matches the width and height attributes of the svg:image element, the image in final generated pdf looks fine. But if the image size is bigger than the width/height attributes of the svg:image element, then the quality of the image in the final pdf is very bad. I include the png file in svg section of .fo file through svg:image width=350 height=280 x=1mm y=80 xlink:href=p2.png/ Have you tried running your SVG using Batik's squiggle? Does it look okay there. If not, then this question should really be directed at the Batik guys, because FOP uses Batik to handle its SVG. If it does look okay in squiggle, then there could be an issue in FOP's SVG-PDF Transcoder. One other question: Does the image inside the SVG look okay if you dont specify width and height attributes on svg:image? Get your own 800 number Voicemail, fax, email, and a lot more http://www.ureach.com/reg/tag On Wed, 4 Feb 2004, Jay Chiu ([EMAIL PROTECTED]) wrote: I generate fo file with svg section to hold absolute positioned text and images. If the image size matches the width and height attributes of the svg:image element, the image in final generated pdf looks fine. But if the image size is bigger than the width/height attributes of the svg:image element, then the quality of the image in the final pdf is very bad. I include the png file in svg section of .fo file through svg:image width=350 height=280 x=1mm y=80 xlink:href=p2.png/ But the png file directly included in .fo scales fine. fo:external-graphic src=url('p1.png') width=120px height=100px/ I use jfreechart to generate the chart image. Because of jfreechart's implementation, I have to generate a big chart image and put it into a smaller space to have high resolution. Attached please find a fo file and the generated pdf file. Can someone please tell me how to solve this problem? Thank you very much. Jay Get your own 800 number Voicemail, fax, email, and a lot more http://www.ureach.com/reg/tag ATTACHMENT 1: application/pdf DISPOSITION: attachment; filename=r3.pdf ATTACHMENT 2: application/octet-stream DISPOSITION: attachment; filename=r.fo - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] png.svg Description: Binary data attachment: p.pngattachment: png.png- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with scaling png image file in svg section
Jay Chiu wrote: I generate fo file with svg section to hold absolute positioned text and images. If the image size matches the width and height attributes of the svg:image element, the image in final generated pdf looks fine. But if the image size is bigger than the width/height attributes of the svg:image element, then the quality of the image in the final pdf is very bad. I include the png file in svg section of .fo file through svg:image width=350 height=280 x=1mm y=80 xlink:href=p2.png/ Have you tried running your SVG using Batik's squiggle? Does it look okay there. If not, then this question should really be directed at the Batik guys, because FOP uses Batik to handle its SVG. If it does look okay in squiggle, then there could be an issue in FOP's SVG-PDF Transcoder. One other question: Does the image inside the SVG look okay if you dont specify width and height attributes on svg:image? But the png file directly included in .fo scales fine. fo:external-graphic src=url('p1.png') width=120px height=100px/ fo:external-graphics are handled entirely within FOP. snip/ Chris - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]