public static void displayImageInfo(ImageInfo info) { ImageSize size = info.getSize(); Dimension2D dPt = size.getDimensionPt(); Dimension dPx = size.getDimensionPx(); log.debug(info.getOriginalURI() + " " + info.getMimeType() + " " + Math.round(dPx.getWidth()) + "x" + Math.round(dPx.getHeight())); log.debug("Resolution:" + Math.round(size.getDpiHorizontal()) + "x" + Math.round(size.getDpiVertical())); log.debug("Print size: " + Math.round(dPt.getWidth() / 72) + "\" x" + Math.round(dPt.getHeight() / 72) + "\""); }
&& (info.getMimeType().equals(ContentTypes.IMAGE_TIFF) || info.getMimeType().equals(ContentTypes.IMAGE_EMF2) // ImageInfo || info.getMimeType().equals(ContentTypes.IMAGE_WMF) || info.getMimeType().equals(ContentTypes.IMAGE_PNG) || info.getMimeType().equals(ContentTypes.IMAGE_JPEG) || info.getMimeType().equals(ContentTypes.IMAGE_GIF) || info.getMimeType().equals(ContentTypes.IMAGE_BMP))) {
String ext = info.getMimeType().substring(info.getMimeType().indexOf("/") + 1); info.getMimeType(), createImageName(opcPackage, sourcePart, proposedRelId, ext), null);
String ext = info.getMimeType().substring(info.getMimeType().indexOf("/") + 1); info.getMimeType(), createImageName(opcPackage, sourcePart, proposedRelId, ext), null);
String ext = info.getMimeType().substring(info.getMimeType().indexOf("/") + 1); info.getMimeType(), createImageName(opcPackage, sourcePart, proposedRelId, ext), null);
/** {@inheritDoc} */ public Image loadImage(ImageInfo info, Map hints, ImageSessionContext session) throws ImageException, IOException { if (!JLaTeXMathObj.MIME_TYPE.equals(info.getMimeType())) { throw new IllegalArgumentException("ImageInfo must be from an LaTeX image"); } final Image img = info.getOriginalImage(); if (!(img instanceof ImageJLaTeXMath)) { throw new IllegalArgumentException("ImageInfo was expected to contain the JLaTeXMath image"); } ImageJLaTeXMath jlmImage = (ImageJLaTeXMath) img; return jlmImage; } }
/** {@inheritDoc} */ public String toString() { return getOriginalURI() + " (" + getMimeType() + ")"; }
/** {@inheritDoc} */ public Image loadImage(ImageInfo info, Map hints, ImageSessionContext session) throws ImageException, IOException { if (!ImageWMF.MIME_WMF.equals(info.getMimeType())) { throw new IllegalArgumentException("ImageInfo must be from a WMF image"); } Image img = info.getOriginalImage(); if (!(img instanceof ImageWMF)) { throw new IllegalArgumentException( "ImageInfo was expected to contain the Windows Metafile (WMF)"); } ImageWMF wmfImage = (ImageWMF)img; return wmfImage; }
/** {@inheritDoc} */ @Override public void handleImage(RenderingContext context, Image image, Rectangle pos) throws IOException { if (log.isDebugEnabled()) { log.debug("Embedding undecoded image data (" + image.getInfo().getMimeType() + ") as data container..."); } super.handleImage(context, image, pos); }
public static void displayImageInfo(ImageInfo info) { ImageSize size = info.getSize(); Dimension2D dPt = size.getDimensionPt(); Dimension dPx = size.getDimensionPx(); log.debug(info.getOriginalURI() + " " + info.getMimeType() + " " + Math.round(dPx.getWidth()) + "x" + Math.round(dPx.getHeight())); log.debug("Resolution:" + Math.round(size.getDpiHorizontal()) + "x" + Math.round(size.getDpiVertical())); log.debug("Print size: " + Math.round(dPt.getWidth() / 72) + "\" x" + Math.round(dPt.getHeight() / 72) + "\""); }
/** {@inheritDoc} */ public Image loadImage(ImageInfo info, Map hints, ImageSessionContext session) throws ImageException, IOException { if (!MimeConstants.MIME_SVG.equals(info.getMimeType())) { throw new IllegalArgumentException("ImageInfo must be from an SVG image"); } Image img = info.getOriginalImage(); if (!(img instanceof ImageXMLDOM)) { throw new IllegalArgumentException( "ImageInfo was expected to contain the SVG document as DOM"); } ImageXMLDOM svgImage = (ImageXMLDOM)img; if (!SVGDOMImplementation.SVG_NAMESPACE_URI.equals(svgImage.getRootNamespace())) { throw new IllegalArgumentException( "The Image is not in the SVG namespace: " + svgImage.getRootNamespace()); } return svgImage; }
String mime = imageInfo.getMimeType(); Map flavorMap = (Map)loaders.get(mime); if (flavorMap != null) {
/** {@inheritDoc} */ public Image loadImage(ImageInfo info, Map hints, ImageSessionContext session) throws ImageException, IOException { if (!this.mime.equals(info.getMimeType())) { throw new IllegalArgumentException( "ImageInfo must be from a image with MIME type: " + this.mime); } Source src = session.needSource(info.getOriginalURI()); ImageRawStream rawImage = new ImageRawStream(info, getTargetFlavor(), XmlSourceUtil.needInputStream(src)); return rawImage; }
/** {@inheritDoc} */ public Image loadImage(ImageInfo info, Map hints, ImageSessionContext session) throws ImageException, IOException { if (!MimeConstants.MIME_EPS.equals(info.getMimeType())) { throw new IllegalArgumentException( "ImageInfo must be from a image with MIME type: " + MimeConstants.MIME_EPS); } Source src = session.needSource(info.getOriginalURI()); InputStream in = XmlSourceUtil.needInputStream(src); XmlSourceUtil.removeStreams(src); //so others cannot close them, we take them over PreloaderEPS.EPSBinaryFileHeader binaryHeader; binaryHeader = (PreloaderEPS.EPSBinaryFileHeader)info.getCustomObjects().get( PreloaderEPS.EPS_BINARY_HEADER); if (binaryHeader != null) { //Binary EPS: just extract the EPS part in.skip(binaryHeader.getPSStart()); in = new SubInputStream(in, binaryHeader.getPSLength(), true); } ImageRawEPS epsImage = new ImageRawEPS(info, in); return epsImage; }
/** {@inheritDoc} */ public Image loadImage(ImageInfo info, Map hints, ImageSessionContext session) throws ImageException, IOException { if (!MimeConstants.MIME_PNG.equals(info.getMimeType())) { throw new IllegalArgumentException("ImageInfo must be from a image with MIME type: " + MimeConstants.MIME_PNG); } Source src = session.needSource(info.getOriginalURI()); ImageInputStream in = ImageUtil.needImageInputStream(src); // Remove streams as we do things with them at some later time. XmlSourceUtil.removeStreams(src); SeekableStream seekStream = new ImageInputStreamSeekableStreamAdapter(in); PNGFile im = new PNGFile(seekStream); ImageRawPNG irpng = im.getImageRawPNG(info); return irpng; }
/** {@inheritDoc} */ public void generateForm(RenderingContext context, Image image, PSImageFormResource form) throws IOException { PSRenderingContext psContext = (PSRenderingContext)context; PSGenerator gen = psContext.getGenerator(); ImageRendered imageRend = (ImageRendered)image; ImageInfo info = image.getInfo(); String imageDescription = info.getMimeType() + " " + info.getOriginalURI(); RenderedImage ri = imageRend.getRenderedImage(); FormGenerator formGen = new ImageFormGenerator( form.getName(), imageDescription, info.getSize().getDimensionPt(), ri, false); formGen.generate(gen); }
/** {@inheritDoc} */ public void generateForm(RenderingContext context, Image image, PSImageFormResource form) throws IOException { PSRenderingContext psContext = (PSRenderingContext) context; PSGenerator gen = psContext.getGenerator(); ImageRawPNG png = (ImageRawPNG) image; ImageInfo info = image.getInfo(); String imageDescription = info.getMimeType() + " " + info.getOriginalURI(); ImageEncoder encoder = new ImageEncoderPNG(png); FormGenerator formGen = new ImageFormGenerator(form.getName(), imageDescription, info.getSize() .getDimensionPt(), info.getSize().getDimensionPx(), encoder, png.getColorSpace(), false); formGen.generate(gen); }
/** {@inheritDoc} */ public void generateForm(RenderingContext context, Image image, PSImageFormResource form) throws IOException { PSRenderingContext psContext = (PSRenderingContext)context; PSGenerator gen = psContext.getGenerator(); ImageRawCCITTFax ccitt = (ImageRawCCITTFax)image; ImageInfo info = image.getInfo(); String imageDescription = info.getMimeType() + " " + info.getOriginalURI(); ImageEncoder encoder = new ImageEncoderCCITTFax(ccitt); FormGenerator formGen = new ImageFormGenerator( form.getName(), imageDescription, info.getSize().getDimensionPt(), info.getSize().getDimensionPx(), encoder, ccitt.getColorSpace(), 1, false); formGen.generate(gen); }
/** {@inheritDoc} */ public void generateForm(RenderingContext context, Image image, PSImageFormResource form) throws IOException { PSRenderingContext psContext = (PSRenderingContext)context; PSGenerator gen = psContext.getGenerator(); ImageRawJPEG jpeg = (ImageRawJPEG)image; ImageInfo info = image.getInfo(); String imageDescription = info.getMimeType() + " " + info.getOriginalURI(); ImageEncoder encoder = new ImageEncoderJPEG(jpeg); FormGenerator formGen = new ImageFormGenerator( form.getName(), imageDescription, info.getSize().getDimensionPt(), info.getSize().getDimensionPx(), encoder, jpeg.getColorSpace(), jpeg.isInverted()); formGen.generate(gen); }
@Override protected void drawImageUsingURI(String uri, Rectangle rect) { ImageManager manager = getUserAgent().getImageManager(); ImageInfo info = null; try { ImageSessionContext sessionContext = getUserAgent().getImageSessionContext(); info = manager.getImageInfo(uri, sessionContext); if (accessEnabled) { PDFStructElem structElem = (PDFStructElem) getContext().getStructureTreeElement(); String mimeType = info.getMimeType(); if (!mimeType.equalsIgnoreCase("application/pdf")) { prepareImageMCID(structElem); } } drawImageUsingImageHandler(info, rect); } catch (ImageException ie) { ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get( getUserAgent().getEventBroadcaster()); eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null); } catch (FileNotFoundException fe) { ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get( getUserAgent().getEventBroadcaster()); eventProducer.imageNotFound(this, (info != null ? info.toString() : uri), fe, null); } catch (IOException ioe) { ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get( getUserAgent().getEventBroadcaster()); eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null); } }