How can I generate images of basic figures with Perl? - perl

I am using jalava library as a diagram drawing tool.
It displays figures as images in order to maintain compatibility with majority of browsers.
When diagram block is being resized a request is being made and new gif image is generated and send to browser.
What I need is generating image of basic blocks, like rounded rectangle, circle, diamond with specified parameters (height, width and color).
I want to do all server-side; my server part is written on Perl.

You can use:
PerlMagick: "PerlMagick is an objected-oriented Perl interface to ImageMagick"
Or
GD

Imager is my favorite such tool.

Related

Real cropping a PDF file

In ghostscript-crop-pdf-not-correctly,I got a cropped PDF,but it's only seemingly cropped.The remaining content still exists in fact.
In ghostscript-removes-content-outside-the-crop-box or
how-to-truly-crop-a-pdf-file or pdf-real-cropping or cropping-a-pdf-using-ghostscript-9-01 or itext-crop-out-a-part-of-pdf-file, no solution was found.May be a virtual PDF printer is the only way.
Use ghostscript or itext, Is there any way to clip a PDF file really.
A very straightforward (but perhaps not the most intelligent) way of solving your problem is to use pdfSweep.
pdfSweep is an iText7 addon that allows you to redact (remove) content.
It allows you to remove content by:
specifying a regular expression
specifying a rectangle (or rectangles)
In your case, you could calculate the rectangles you want removed, and then apply pdfSweep.
If you then crop the remaining page, the content would really be gone.
More information (including code samples) can be found here.
What leads you to believe that the content is still present ?
Any object which is not at least partially contained within the page clip will not be forwarded on to the pdfwrite device by Ghostscript, so I'm doubtful that content is preserved.
Your original question related to cropping away white space, so that makes your example file less than useful in this case. You should post an example of the problem file, and the Ghostscript command line you have used.
Note that if you are trying to crop out an image then no, this won't do what you want. If any part of the image lies on the media, then the entire image will be included in the file. The pdfwrite device isn't equipped to extract sub-areas from images. This is true for all the PDF editors that I'm aware of.

Delphi - How to make a PNG image the main form?

I have an application which the main form of it its called Fmain. How can i make the Fmain to be the PNG image which i have as Image1 assigned in my source?
FMain.brush.bitmap:=Image1.picture.bitmap;
that's for if the Image1 is a *.bmp one, but i need the transperancy of my PNG file.
I don't think you will be able to make a custom shaped TForm with a transparent png.
Have a a look at this answer Irregularly shaped forms and more specifically to this http://docwiki.embarcadero.com/Libraries/XE2/en/Vcl.Forms.TCustomForm.TransparentColorValue .
Are you wanting to make a form that has an odd shape? As in, you want to have the transparent parts of the PNG not be clickable as a form? If so then you are going about it the wrong way. If you were to put an image on the form and set the transparent properties on the image, then all you will do is see the form behind the image.
If you want to have a form that is the shape of the visible area of the PNG then you need to create an oddly shaped form. This is done by using regions and SetWindowRgn.
Luckily there is a handy tool out there for this: Gabes OddForm Assistant. I have used this to great effect a number of times.
In order to use it you will need to save your PNG as a bitmap and then load it into the utility. Once it is done it will give you the code required to make the form. You can just have a look in the pas file it creates and see how it is done, tinkering if you feel the need. You can either use the form directly or graft the code to where you need it.
Hope this helps.

What are the differences between APNG and MNG?

I know that APNG is an extension of PNG, while MNG is more of its own format (albeit developed by the original PNG developers). MNG is barely supported in any browser at all, while APNG almost only has native support in Firefox (for various backward compatibility- and decoding-related reasons, it seems).
Except all of these behind-the-scenes things, what are the differences between APNG and MNG? Does one have features the other doesn't (for example, storing only parts that are modified instead of always whole frames)? Does one have better performance or file size than the other?
APNG can create a new frame by replacing the entire image or by overlaying or blending a smaller image over part of it. To display a "pong" game you'd need a new image of the ball in each different location. APNG has essentially the same capabilities as animated GIF, but also allowing 24bit RGB and 8-bit alpha.
MNG can do that, plus it can also retrieve an image that was previously defined in the datastream and place it over the previous frame in a new location. To display your "pong" game you'd only need to transmit one image of the ball and use it like a sprite.
Much more detail is available in the specifications:
apng: (https://wiki.mozilla.org/APNG_Specification‎)
mng: (http://www.libpng.org/pub/mng/spec/mng-lc.html)

Can we identify image having any overlay using quartz?

I have to work with image which is coming from some server. We want to process that image so that we can find out does it contain any specific color region.
Is there any way so that the image coming from server will be overlaid image & on device side we can process it to check if it contains those overlays?
I have never being worked on quartz stuff. If anybody can suggest some other solution?
There are several ways to do this depending on how complex you wish to get. OpenCV has image blocking which can segregate images into distinct regions. Or check out Image tools especially blob extraction and then look at the general pixel colouration in a single blob.

Generating icons for iPhone UITabBar

I’ve been busy working on the graphics for my iPhone application. I started working on generating icons for my UITabBar and ran into lots of problems. How do you create these icons?
I created this solution:
http://www.nailrails.com/?p=46
Are there any shortcomings to this approach? It seemed to work for the few icons I created...
Apple's guidelines can be found at http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/IconsImages/IconsImages.html#//apple_ref/doc/uid/TP40006556-CH14-SW1
The docs are pretty straightforward-- alpha is all that matters when the image gets loaded by the toolbar, meaning that anything that's not at least semitransparent will render in the same opaque shade. As for how I do that, I mainly use Adobe tools. Fireworks is my preferred tool but Photoshop's also more than up to it. Another one I've had good results with is Acorn, which is frankly a lot cheaper while being more than sophisticated enough for this kind of work. I'm not really a graphic designer but a certain familiarity with this kind of stuff goes with the job.
I have an article up on my site that shows how to use OmniGraffle with a template I use to create great iPhone toolbar icons in minutes:
http://steveweller.com/articles/toolbar-icons/
The template sets up a grid to work to that corresponds to one square for each pixel. You draw your icon in white on top of the black template background and then export as a PDF exactly the right area to match the icon size you need (typically 21 pixels high). Then you reimport the PDF, resize it to the final icon size (21 pixels again), and export as PNG. The template does nothing magical; it just provides an already set up working area and helps you get the final PNG right every time to the scale is correct.
You could use the same technique in Acorn or any other app that supports PDF export and layers.
(I use Gimp. Assume your icon layer already has alpha channel.)
Right click the layer, then add layer mask.
Done with option "transfer alpha channel of layer" chosen.
Select the whole layer (but not layer mask), and clear it with pure white.
Resize image to Apple-suggested size, and export it as png file.
You may also paint directly on the layer mask.