2

I wrote a simple task to scale my images, but it seems to have problem with PNG files.

Here's the contents of the task [the important part of it]:

 <image srcdir="${imgResizeDir}" destdir="${imgResizeDir}/md" overwrite="yes" >
            <scale width="75%" height="75%"/>
            <regexpmapper from="^(.*)-hd\.(.*)$$" to="\1-md.\2"/>
 </image>

When I run this I end up with this error:

Error: IOException occurs when search for propriate codecs.
Occurs in: com.sun.media.jai.codec.ImageCodec
java.io.IOException: Bad file descriptor
    at java.io.RandomAccessFile.seek(Native Method)
    at com.sun.media.jai.codec.FileSeekableStream.readPage(FileSeekableStream.java:141)
    at com.sun.media.jai.codec.FileSeekableStream.read(FileSeekableStream.java:181)
    at com.sun.media.jai.codec.SeekableStream.readFully(SeekableStream.java:327)
    at com.sun.media.jai.codec.SeekableStream.readFully(SeekableStream.java:306)
    at com.sun.media.jai.codec.ImageCodec.getDecoderNames(ImageCodec.java:274)
    at com.sun.media.jai.opimage.StreamRIF.create(StreamRIF.java:80)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at javax.media.jai.FactoryCache.invoke(FactoryCache.java:130)
    at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1679)
    at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:481)
    at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:340)
    at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:830)
    at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:878)
    at javax.media.jai.RenderedOp.getRendering(RenderedOp.java:899)
    at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:810)
    at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:878)
    at javax.media.jai.RenderedOp.getRendering(RenderedOp.java:899)
    at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:810)
    at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:878)
    at javax.media.jai.RenderedOp.getRendering(RenderedOp.java:899)
    at javax.media.jai.JAI.createNS(JAI.java:1103)
    at javax.media.jai.JAI.create(JAI.java:977)
    at javax.media.jai.JAI.create(JAI.java:1672)
    at org.apache.tools.ant.taskdefs.optional.image.Image.processFile(Image.java:320)
    at org.apache.tools.ant.taskdefs.optional.image.Image.processDir(Image.java:253)
    at org.apache.tools.ant.taskdefs.optional.image.Image.execute(Image.java:374)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:390)
    at org.apache.tools.ant.Target.performTasks(Target.java:411)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.apache.tools.ant.Main.runBuild(Main.java:809)
    at org.apache.tools.ant.Main.startAnt(Main.java:217)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:29)
java.lang.RuntimeException: - Unable to render RenderedOp for this operation.
    at org.apache.tools.ant.taskdefs.optional.image.Image.processFile(Image.java:343)
    at org.apache.tools.ant.taskdefs.optional.image.Image.processDir(Image.java:253)
    at org.apache.tools.ant.taskdefs.optional.image.Image.execute(Image.java:374)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:390)
    at org.apache.tools.ant.Target.performTasks(Target.java:411)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.apache.tools.ant.Main.runBuild(Main.java:809)
    at org.apache.tools.ant.Main.startAnt(Main.java:217)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:29)
Caused by: java.lang.RuntimeException: - Unable to render RenderedOp for this operation.
    at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:838)
    at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:878)
    at javax.media.jai.RenderedOp.getRendering(RenderedOp.java:899)
    at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:810)
    at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:878)
    at javax.media.jai.RenderedOp.getRendering(RenderedOp.java:899)
    at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:810)
    at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:878)
    at javax.media.jai.RenderedOp.getRendering(RenderedOp.java:899)
    at javax.media.jai.JAI.createNS(JAI.java:1103)
    at javax.media.jai.JAI.create(JAI.java:977)
    at javax.media.jai.JAI.create(JAI.java:1672)
    at org.apache.tools.ant.taskdefs.optional.image.Image.processFile(Image.java:320)
    ... 24 more

If I remove the % sign from width and height I end up with images with proper dimensions, but PNGs are screwed [they look like covered with semitransparent black layer]. Most of the images are PNG and I have to use %.

I'm running this task using Apache Ant 1.8.2 on MacOS Lion. Java version: 1.6.0_31

Is there something I should add to my ant to make this work?

Thanks

Perception
  • 79,279
  • 19
  • 185
  • 195
Krystian
  • 3,193
  • 2
  • 33
  • 71
  • The first line of the error indicates that proprietary codecs could not be loaded. You may want to take a look at these threads for correcting missing codecs on Mac OS X Lion: 1) [Missing codecs in QT7 Pro on Lion](https://discussions.apple.com/thread/3503820?start=0&tstart=0) 2) [Installing PIL with JPEG support on Mac OS X](http://stackoverflow.com/questions/8404956/installing-pil-with-jpeg-support-on-mac-os-x) – Christopher Peisert May 26 '12 at 06:33

0 Answers0