You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by je...@apache.org on 2010/07/27 09:50:40 UTC

svn commit: r979567 - in /xmlgraphics/commons/trunk: src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java status.xml

Author: jeremias
Date: Tue Jul 27 07:50:40 2010
New Revision: 979567

URL: http://svn.apache.org/viewvc?rev=979567&view=rev
Log:
Fix for TIFFs which report zero as their resolution. This resulted in an exception.

Modified:
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java
    xmlgraphics/commons/trunk/status.xml

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java?rev=979567&r1=979566&r2=979567&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java Tue Jul 27 07:50:40 2010
@@ -127,7 +127,10 @@ public class PreloaderTIFF extends Abstr
                     xRes = fldx.getAsFloat(0);
                     yRes = fldy.getAsFloat(0);
                 }
-                if (unit == 2) {
+                if (xRes == 0 || yRes == 0) {
+                    //Some TIFFs may report 0 here which would lead to problems
+                    size.setResolution(context.getSourceResolution());
+                } else if (unit == 2) {
                     size.setResolution(xRes, yRes); //Inch
                 } else {
                     size.setResolution(

Modified: xmlgraphics/commons/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/status.xml?rev=979567&r1=979566&r2=979567&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/status.xml (original)
+++ xmlgraphics/commons/trunk/status.xml Tue Jul 27 07:50:40 2010
@@ -40,6 +40,9 @@
   </contexts>
   <changes>
     <release version="Trunk" date="n/a">
+      <action context="Code" dev="JM" type="fix">
+        Fix for TIFFs which report zero as their resolution. This resulted in an exception.
+      </action>
     </release>
     <release version="1.4" date="7 July 2010">
       <action context="Code" dev="JM" type="fix" fixes-bug="49364" due-to="Julien Aymé">



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org


Re: svn commit: r979567 - in /xmlgraphics/commons/trunk: src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java status.xml

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
On 27.07.2010 17:02:12 Vincent Hennebert wrote:
> Jeremias Maerki wrote:
> > Hi Vincent
> > 
> > 
> > On 27.07.2010 12:56:42 Vincent Hennebert wrote:
> >> Hi,
> >>
> >>> Author: jeremias
> >>> Date: Tue Jul 27 07:50:40 2010
> >>> New Revision: 979567
> >>>
> >>> URL: http://svn.apache.org/viewvc?rev=979567&view=rev
> >>> Log:
> >>> Fix for TIFFs which report zero as their resolution. This resulted in an exception.
> >>> Modified: 
> >>> xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java
> >>> ==============================================================================
> >>> @@ -127,7 +127,10 @@ public class PreloaderTIFF extends Abstr
> >>>                      xRes = fldx.getAsFloat(0);
> >>>                      yRes = fldy.getAsFloat(0);
> >>>                  }
> >>> -                if (unit == 2) {
> >>> +                if (xRes == 0 || yRes == 0) {
> >>> +                    //Some TIFFs may report 0 here which would lead to problems
> >> Isn’t it a degenerate case that the user wants to be made aware of?
> > 
> > Not IMO. The users can always size the images to their wishes.
> 
> So that’s done by setting resolution to 0?

No, what I mean is that people can use the properties on
fo:external-graphic and svg:image to scale the images to their wishes. A
missing resolution is just a fact of life in some very rare cases (for
TIFF).

> >> Also, what if xRes == 0 but yRes != 0 or vice versa?
> > 
> > That's a very interesting question...
> 
> Ok, so I assume my question was actually stupid. Might well be as
> I don’t know anything about TIFF. I thought that maybe the non-null
> resolution could be used for both axes, instead of relying on an
> external arbitrary value. But I suppose that doesn’t matter.

There are generally no stupid questions. But this one was kind of
academic which is why I reacted like this. Of course, we could handle
these two cases, too, but even the case I've fixed happens very rarely.
I estimate a probability of less than 0.0001 that this special case
you raised ever happens so rather than further complicating the code, I
chose a compromise that nobody is likely to ever stumble on in practice,
only when someone is reading the code. The resolution is only a hint.
Most people will scale their images anyway in which case the resolution
doesn't matter at all.


Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


Re: svn commit: r979567 - in /xmlgraphics/commons/trunk: src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java status.xml

Posted by Vincent Hennebert <vh...@gmail.com>.
Jeremias Maerki wrote:
> Hi Vincent
> 
> 
> On 27.07.2010 12:56:42 Vincent Hennebert wrote:
>> Hi,
>>
>>> Author: jeremias
>>> Date: Tue Jul 27 07:50:40 2010
>>> New Revision: 979567
>>>
>>> URL: http://svn.apache.org/viewvc?rev=979567&view=rev
>>> Log:
>>> Fix for TIFFs which report zero as their resolution. This resulted in an exception.
>>> Modified: 
>>> xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java
>>> ==============================================================================
>>> @@ -127,7 +127,10 @@ public class PreloaderTIFF extends Abstr
>>>                      xRes = fldx.getAsFloat(0);
>>>                      yRes = fldy.getAsFloat(0);
>>>                  }
>>> -                if (unit == 2) {
>>> +                if (xRes == 0 || yRes == 0) {
>>> +                    //Some TIFFs may report 0 here which would lead to problems
>> Isn’t it a degenerate case that the user wants to be made aware of?
> 
> Not IMO. The users can always size the images to their wishes.

So that’s done by setting resolution to 0?


>> Also, what if xRes == 0 but yRes != 0 or vice versa?
> 
> That's a very interesting question...

Ok, so I assume my question was actually stupid. Might well be as
I don’t know anything about TIFF. I thought that maybe the non-null
resolution could be used for both axes, instead of relying on an
external arbitrary value. But I suppose that doesn’t matter.

Vincent

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


Re: svn commit: r979567 - in /xmlgraphics/commons/trunk: src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java status.xml

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Hi Vincent


On 27.07.2010 12:56:42 Vincent Hennebert wrote:
> Hi,
> 
> > Author: jeremias
> > Date: Tue Jul 27 07:50:40 2010
> > New Revision: 979567
> > 
> > URL: http://svn.apache.org/viewvc?rev=979567&view=rev
> > Log:
> > Fix for TIFFs which report zero as their resolution. This resulted in an exception.
> > Modified: 
> > xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java
> > ==============================================================================
> > @@ -127,7 +127,10 @@ public class PreloaderTIFF extends Abstr
> >                      xRes = fldx.getAsFloat(0);
> >                      yRes = fldy.getAsFloat(0);
> >                  }
> > -                if (unit == 2) {
> > +                if (xRes == 0 || yRes == 0) {
> > +                    //Some TIFFs may report 0 here which would lead to problems
> 
> Isn’t it a degenerate case that the user wants to be made aware of?

Not IMO. The users can always size the images to their wishes.

> Also, what if xRes == 0 but yRes != 0 or vice versa?

That's a very interesting question...


Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


Re: svn commit: r979567 - in /xmlgraphics/commons/trunk: src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java status.xml

Posted by Vincent Hennebert <vh...@gmail.com>.
Hi,

> Author: jeremias
> Date: Tue Jul 27 07:50:40 2010
> New Revision: 979567
> 
> URL: http://svn.apache.org/viewvc?rev=979567&view=rev
> Log:
> Fix for TIFFs which report zero as their resolution. This resulted in an exception.
> Modified: 
> xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java
> ==============================================================================
> @@ -127,7 +127,10 @@ public class PreloaderTIFF extends Abstr
>                      xRes = fldx.getAsFloat(0);
>                      yRes = fldy.getAsFloat(0);
>                  }
> -                if (unit == 2) {
> +                if (xRes == 0 || yRes == 0) {
> +                    //Some TIFFs may report 0 here which would lead to problems

Isn’t it a degenerate case that the user wants to be made aware of?
Also, what if xRes == 0 but yRes != 0 or vice versa?


Thanks,
Vincent

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org