I have an svg file and I want to convert it to image png, I am searching any class that do this in ABAP but I could not find any results.
I tried to do this with Javascript then execute it from ABAP but my code in JS should be without DOM implementation or browser functionalities to be able to run it from ABAP.
SVG is - as its name implies - a vector graphics format while PNG is a raster graphics format. Converting vector graphics to raster graphics requires all kinds of "interesting" capabilities that ABAP isn't really suitable for, for instance rendering text in (almost) any font with various attributes and modifiers into a bitmap. I would be surprised if a pure ABAP solution existed at all. It should be possible from a technical point of view, but as you might imagine, it'd be an enormous task.
That being said, you might want to try to use the IMGCONV part of the Internet Graphics Service. I'm not sure whether it support SVG, but you might want to check out the classes CL_IGS_*.
You could try doing this with a GUI attached running windows. If that's an option. The back-end server-side Java interpreter does lack a DOM, yes. But perhaps you can find a library that can do this in Java without a DOM? Should be easier than doing the bit manipulations required in ABAP.
you cannot convert an SVG into a PNG or JPEG in abap.
First of all you have to download the SVG file and open it in Paint, if you use win. Then save it as bitmap in 256 color. After that you can convert it into png files. (why? If you load the file without converting it to 256-color bitmaps, SAP may not interpret the colors well. Withe can became gray and gray can became blu)
Advice: if you want to use the image in smartforms or adobeforms or sapscritp, best way is to upload it in bitmap in se78 transaction and call it in you printouts or alv header
Related
We are thinking about a library which can get a TIFF image and display each page (frame) of TIFF file in a separate canvas element. Also some pages might have layers. We want to be able to show/hide layers at user's will.
It is not necessary to tell me the complete solution or library. Just tell me if it is possible to accomplish all these requirements by javascript or we need to get help of server-side programming?
Should be possible. I don't think browsers support the TIFF format natively, but a quick Google search turns up at least two TIFF parsers for JavaScript. From there on, you can display it in any way you like; tiff.js even has a multipage demo.
node-canvas is a Node.js version of the HTML5 canvas library that depends on Cairo. My app creates a bunch of PNG files depending on that data that is sent to the app.
node-canvas offers two functions toBuffer() and toDataURL() which outputs raw PNG or Base64 encoded PNG to a string which I can send to the browser. However there is no way to add support for interlacing in the library.
I'd like to extend the functionality of the library and add support for interlaced PNGs. I have the raw PNG data in a string, and also an array of pixels for the image (if need be). I do not have an understanding of how PNG encoding works. Can someone please point me to the algorithm I need to use to convert the data I have, either the non-interlaced raw PNG data or the pixel array and convert it to an interlaced/progressive PNG?
This is a necessary step for the graphing calculator app that I am building that graphs complex equations. It would be good to have a blurry image that appears quickly and sharpens over time than a non-interlaced PNG that loads from top to bottom for my app.
Thanks!
You can't convert a non-interlaced raw PNG data to a interlaced PNG stream. Interlaced vs non-interlaced PNG are two different ways of PNG encoding (they basically differ in the pixel stream ordering, but after that a filter-compression is applied, so you can't simply alter the final stream to switch between interlaced and non-interlaced modes). TO generate an interlaced PNG is work of the PNG encoder, the one which is used to write your PNG files (or stream) from the raw image pixels.
Nevertheless, I'd advise you against interlaced images; the compression efficiency suffers (specially with PNG) and the advantage for the user experience is at least debatable. See eg. Today, interlaced PNG is seldom used.
I would like to convert a PNG or JPEG file to SVG. But I can't find anything on how to do it. The thing is I'm using devexpress reports to export it to image so the format can either be .jpg or .png. Now what I want is to convert it to SVG so that the image will still be in a better quality when passing it through Javascript and finally to Objective-C.
To explain a bit further.
I have a service which is coded using VB.net. This is server side; client side is Javascript and HTML: I'm using Phonegap to bridge Objective-C. What I'm doing really is creating a plugin which would pass a URL from Javascript and have Objective-C catch the url, then load it as an image and pass it to the ePOS SDK to print as an image.
What I noticed is that when I'm exporting the report using devexpress as a png, the image gets pixelated and a bit grainy because I'm scaling the image to make it bigger to fill the thermal paper (80mm). That's why instead of PNG I want it in SVG to preserve the quality of the image.
My question is where should I convert the image? On the server side or in Objective-C? And how will I do such a daunting task? I was thinking of doing it in Objective-C, but I think it is much better to convert it on the server side. What do you think?
Also is it possible to convert .png or .jpeg to a .svg file?
Thanks
You could do it on the server side with ImageMagick, but I think that since you'll be converting a bitmap image to vector graphics, you'll just get the same low-quality crap. Can you export your reports to PDF or another vector graphics format?
For browsers that don't support SVG, I'd like to show a static image of a chart instead of an interactive version.
One idea is to generate all possible chart states (around 300) beforehand. I tried using the Canvas2Image library but it doesn't seem to allow me to specify a filename. Is there any workaround? Perhaps a server-side solution?
There's a couple other ways to solve this.
rsvg is a rendering library that processes SVGs statically single-pass. It's used in ImageMagick's convert tool, and also has python and other bindings. Some people find various SVG-isms aren't supported, but rsvg gets updates now and then so best to just try and see.
inkscape is a GUI program that includes SVG->PNG conversion. But it can also be used exclusively on the command line (no X11 required). See man inkscape for all the command line options that can be used to process your svg's; it's quite flexible. The rendering is relatively fast. The main downside is that being a GUI program it has a lot of dependencies, that might not be present on a web server.
Since File API will enable access to the content of local files it is now possible to do image resize before upload (a fairly common task) without any additional technology like Flash or Silverlight. Except that I can't find any Javascript library that would be able to handle images in binary form. Is there any? Maybe there is some in Flashe's ECMA script that could be adapted, but I simply can't find anything.
Although I haven't find such libs, I have found a way how to accomplish the described task:
Read image as Data URL
Load an image into a canvas tag and resize it
Encode canvas image data into some image format, for example JPG. Or use Canvas.toDataUrl() and then (optionaly) some base64 decoder.
Client side image resizing and upload with pure javascript. That's cool, isn't it?
Even if you do find something that understands images in pure javascript, you would still need the DOM to render it, making it incredibly slow.
Don't know if this is what you want, but there are some scripts on Userscripts.org that handle images: http://userscripts.org/scripts/show/38736
One problem with calavera.info's answer (sorry I cannot seem to comment directly on that answer) is that the call to either CanvasRenderingContext2D.getImageData or Canvas.toDataURL mentioned in the third bullet will fail. They each throw a SECURITY_ERR: DOM Exception 18 as the image is not from the same origin or domain as the document that owns the canvas element. That seems inevitable since the image comes from the local file system (via an input type="file" tag), but the page comes from your web server.