c# - Why does ImageResizer not handle extraction of tiff pages if the tiff has pages of differing image types? -


i'm using imageresizer.net in console app pull pages out of tiff images, when tiff contains pages of differing image types, imageresizer extracts not represent original page.

i using managed api, code: imagebuilder.current.build(sourceimagepath, destinationimagepath, new resizesettings("page=[whatever]"));

the tiff image contains...

  • page 1, image type "bilevel (white zero)", compression "group 3", size "485kb".
  • page 2, image type "ycbcr (2,1 subsampling)", compression "jpeg (old style)", size "11mb".
  • page 3, image type "ycbcr (2,1 subsampling)", compression "jpeg (old style)", size "11mb".
  • page 4, image type "grayscale (256 grays, black zero)", compression "jpeg (old style)", size "4mb".

the behaviour getting is...

  • extracting page 1 works correctly.
  • extracting page 2 ends extracting image of page 1.
  • extracting page 3 ends extracting image of page 1, squashed band 1cm wide on left hand side of image, remaining image black.
  • extracting page 4 works correctly.

i have used libtiff.net extract same images using this method, not exhibit same fault.

edit - using code test wic decoder:

var settings = new resizesettings("decoder=wic&page=" + pagenumber); config.current.plugins.getorinstall<wicdecoderplugin>(); imagebuilder.current.build(sourceimagepath, destimagepath, settings); 

this works page 1 & 4 (no change there), 'object reference not set instance of object.' error page 2 & 3 when using wic decoder.

edit 2 - converted bit that's failing mvc project /resizer.debug:

image resizer diagnostic sheet      29/06/2012 4:08:14 a.m.  4 issues detected:  (warning):  potentially see additional errors here, perform image resize request.   (warning):  running hotfix version of imageresizer.             should upgrade released version equal or higher version number possible. hotfix , release dlls same version number not same - release dll should used instead.             assemblies marked hotfix versions: imageresizer, imageresizer.mvc  (warning):  nocache development usage, , cannot scale production use.             add diskcache or cloudfront production use  (warning):  potentially incompatible imageresizer assemblies detected.             please make sure imageresizer assemblies same version. compatibility issues possible if mix plugins different releases.             3.2.3 assemblies: imageresizer, imageresizer.mvc             3.2.2 assemblies: imageresizer.plugins.logging, imageresizer.plugins.wic   using paid bundles: design bundle  registered plugins:  imageresizer.plugins.basic.defaultencoder imageresizer.plugins.basic.nocache imageresizer.plugins.basic.clientcache imageresizer.plugins.basic.diagnostic imageresizer.plugins.basic.sizelimiting imageresizer.plugins.mvcroutingshim.mvcroutingshimplugin imageresizer.plugins.wicdecoder.wicdecoderplugin imageresizer.plugins.logging.loggingplugin  configuration:  <resizer> <plugins> <add name="mvcroutingshim" /> <add name="wicdecoder" /> <add name="logging" /> </plugins> </resizer>   accepted querystring keys:  quality, format, thumbnail, maxwidth, maxheight, width, height, w, h, scale, stretch, crop, cropxunits, cropyunits, page, bgcolor, rotate, flip, sourceflip, sflip, srotate, borderwidth, bordercolor, paddingwidth, paddingcolor, ignoreicc, frame, useresizingpipeline, cache, process, margin, anchor, dpi, mode, zoom,   accepted file extensions:  bmp, gif, exif, png, tif, tiff, tff, jpg, jpeg, jpe, jif, jfif, jfi,   environment information:  running microsoft windows nt 6.1.7601 service pack 1 , clr 4.0.30319.269 trust level: unrestricted os bitness: x86 !! warning, running 32-bit on 64-bit os(amd64). limit ram usage !! executing assembly: c:\program files (x86)\common files\microsoft shared\devserver\10.0\webdev.webserver40.exe integratedpipeline: false  loaded assemblies:  mscorlib                                 assembly: 4.0.0.0         file: 4.0.30319.269   info: 4.0.30319.269 system.web                               assembly: 4.0.0.0         file: 4.0.30319.272   info: 4.0.30319.272 system                                   assembly: 4.0.0.0         file: 4.0.30319.269   info: 4.0.30319.269 system.core                              assembly: 4.0.0.0         file: 4.0.30319.233   info: 4.0.30319.233 system.configuration                     assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.xml                               assembly: 4.0.0.0         file: 4.0.30319.233   info: 4.0.30319.233 system.runtime.caching                   assembly: 4.0.0.0         file: 4.0.30319.237   info: 4.0.30319.237 microsoft.build.utilities.v4.0           assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.web.regularexpressions            assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 microsoft.build.framework                assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.data                              assembly: 4.0.0.0         file: 4.0.30319.237   info: 4.0.30319.237 microsoft.jscript                        assembly: 10.0.0.0        file: 10.0.30319.1    info: 10.0.30319.1 cppcodeprovider                          assembly: 10.0.0.0        file: 10.0.30319.1    info: 10.0.30319.1 system.web.webpages.deployment           assembly: 1.0.0.0         file: 1.0.20105.407   system.web.webpages                      assembly: 1.0.0.0         file: 1.0.20105.407   system.web.mvc                           assembly: 3.0.0.0         file: 3.0.20105.0     microsoft.web.infrastructure             assembly: 1.0.0.0         file: 1.0.20105.407   system.web.webpages.razor                assembly: 1.0.0.0         file: 1.0.20105.407   system.web.razor                         assembly: 1.0.0.0         file: 1.0.20105.407   app_global.asax.ijrgfwnu                 assembly: 0.0.0.0         pncc.limdocumentbuilder.imageresizertest assembly: 1.0.0.0         file: 1.0.0.0         webdev.webhost40                         assembly: 10.0.0.0        file: 10.0.40219.1    info: 10.0.40219.1 system.web.mobile                        assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.servicemodel.activation           assembly: 4.0.0.0         file: 4.0.30319.233   info: 4.0.30319.233 system.servicemodel                      assembly: 4.0.0.0         file: 4.0.30319.233   info: 4.0.30319.233 system.runtime.durableinstancing         assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 smdiagnostics                            assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.xaml.hosting                      assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.web.extensions                    assembly: 4.0.0.0         file: 4.0.30319.272   info: 4.0.30319.272 microsoft.csharp                         assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.web.services                      assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.drawing                           assembly: 4.0.0.0         file: 4.0.30319.282   info: 4.0.30319.282 system.enterpriseservices                assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.identitymodel                     assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.runtime.serialization             assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.servicemodel.web                  assembly: 4.0.0.0         file: 4.0.30319.233   info: 4.0.30319.233 system.activities                        assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.servicemodel.activities           assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.workflowservices                  assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.data.datasetextensions            assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.xml.linq                          assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.componentmodel.dataannotations    assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.web.dynamicdata                   assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.web.applicationservices           assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 entityframework                          assembly: 4.1.0.0         file: 4.1.10331.0     info: 4.1.10331.0 imageresizer                             assembly: 3.2.3.766       file: 3.2.3.766       info: 3-2-beta-3-temp-hotfix-jun-27-2012-9am  commit: a0f4f1e imageresizer.mvc                         assembly: 3.2.3.766       file: 3.2.3.766       info: 3-2-beta-3-temp-hotfix-jun-27-2012-9am  commit: a0f4f1e imageresizer.plugins.logging             assembly: 3.2.2.0         file: 3.2.2.0         info: 3-2-beta-2  commit: 3704dd6 imageresizer.plugins.wic                 assembly: 3.2.2.0         file: 3.2.2.0         info: 3-2-beta-2  commit: 3704dd6 nlog                                     assembly: 2.0.0.0         system.web.abstractions                  assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 system.web.helpers                       assembly: 1.0.0.0         file: 1.0.20105.407   system.web.routing                       assembly: 4.0.0.0         file: 4.0.30319.1     info: 4.0.30319.1 

update 12/12/2012:

the freeimagedecoder plugin supports multi-page tiff files, , uses libtiff internally. suggested way deal complex/rare .tiff files.


the tiff format extremely complex , poorly standardized. libraries (like gdi+ (system.drawing) , wic (wpf)) implement fraction of standard, let alone de-facto features , additions.

to level of .tiff support, need use library dedicated .tiff support such libtiff or libtiff.net.

imageresizer does integrate libtiff via freeimage , freeimagedecoder plugin, multi-page support hasn't been implemented yet.

you're not creek without paddle - there many ways solve dilemma:

  1. fork freeimagedecoder , add multi-page support. difficulty: 7
  2. subclass builderextension, override decodestream, , glue in libtiff.net. difficulty: 5
  3. subclass builderextension, override decodestream, , glue in libtiff. difficulty: 10
  4. post idea on uservoice site , 30 votes. difficulty:?
  5. pay me it. difficulty: 3 (my next available slot several months now, however).

there 4 example implementations of decoders: imagebuilder.decodestream, psdreader, wicdecoder, freeimagedeocoder, , pdfrenderer. source code them is included in download. average decoder requires less 80 lines of code.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -