Measure if path is set as Clipping path - imagemagick

Our company receives thousands of images every year, that has to be saved in exactly the correct way.
Up till now this has been done by hand by Agencies, but our Indesign server has started to crash when a tiff image has a path but no set clipping path.
I wish to find a way to measure if the clipping path has been set using a tool like exiftool or ImageMagick.
Does anyone have a way to determine if the clipping path has been set ?
I will be checking using Java, so any commandline tool will suffice.

Using ImageMagick's Identify command line tool with option -verbose will output information about any clipping path in the image.

Related

Changing content of an image by script

In a project we use GIMP to create banners (which are saved in the GIMP native format). All the work is done by humans. But it is often tedious work which consists of replacing one logo with an other logo with the same dimensions or one piece of text with an other piece of text. Sometimes many 100 times.
What is the best way to automatically replace an image (with the same dimensions) or a text in a GIMP file? Does it make more sense to script it within GIMP or is it better to do open heard surgery on the file itself without GIMP? Or is there a command line tool which I can use for this?

Octave only prints last line segment plotted

I am having trouble creating plot files with octave. When executing
imagesc([1,2,3],[1,2,3],[1,3,1;3,2,3;1,3,1]);
line([0,1,2,3,4],[1.5,1.3,1.7,1.5,1.9]);
print("test.pdf);
the bitmap image is displayed correctly in the plot window, with a wiggly line superimposed on top. But the .png file only shows the image from "imagesc", plus the last of the four segments drawn by the "line" command. This happens when printing to .png files as well.
I am using octave 4.2.1 on Windows 10, with the "qt" graphics toolkit. Changing toolkits to "fltk" effects no change, while going to "gnuplot" will trigger some error message about the "imagesc" command which I am currently not interested in.
Does anyone know how to get the file output right?
Adding a third dimension to the line coordinates solved my problem. I have implemented the following changes following a workaround found in bug report #51464 on savannah.gnu.org:
imagesc([1,2,3],[1,2,3],[1,3,1;3,2,3;1,3,1]);
line([0,1,2,3,4],[1.5,1.3,1.7,1.5,1.9],[4,4,4,4,4]);
zlim ([0 4]);
print("test.pdf");

Fiji: How can I use the information of the image in order to set the scale?

the images created in the microscope that we use in our lab don't have a scale bar. Can i use the information stored at the image itself/information from the microscope itself, in order to properly set the scale, and convert pixels into nm?
I've downloaded the plugin called "microscope scale", but I don't understand how to use it.
thank you!
Reading the description of the Microscope Scale plugin it sounds like you would need to manually edit the plugin's source code to set the scale for your data.
Instead I would suggest using the Bio-Formats Importer to open your data, as it has a good chance of reading calibration values directly from your images (if they were saved by the microscope).
If Bio-Formats doesn't work, then you can manually set the scale using the Spatial Calibration plugin provided with Fiji to convert pixels to nm.

Finding known text in an image (guided OCR)

I'm looking for a way to locate known text within an image.
Specifically, I'm trying to create a tool convert a set of scanned pages into PDFs that support searching and copy+paste. I understand how this is usually done: OCR the page, retaining the position of the text, and then add the text as an invisible layer to the PDF. Acrobat has this functionality built in, and tesseract can output hOCR files (containing the recognized text along with its location), which can be used by hocr2pdf to generate a text layer.
Unfortunately, my source images are rather low quality (at most 150 DPI, with plenty of JPEG artifacts, and non-solid backgrounds behind some of the text), leading to pretty poor OCR results. However, I do have the a copy of the text (sans pictures and layout) that appears on each page.
Matching already known text to it's location on a scanned page seems like it would be much easier to do accurately, but I failed to discover any software with this capability built-in. How can I leverage existing software to do this?
Edit: The text varies in size and font, though passages of it are consistent.
The thought that springs to mind for me would be a cross-correlation. So, I would take the list of words that you know occur on the page and render them one at a time onto a canvas to create a picture of that word. You would need to use a similar font and size as the words in the document - which is what I asked in my comment. Then I would run a normalised cross-correlation of the picture of the word against the scanned image to see where it occurs. I would do all that with ImageMagick which is available for Windows and OSX (use homebrew on OS X) and included in most Linux distros.
So, let's take a screengrab of the second paragraph of your question and look for the word pretty - where you mention pretty poor OCR.
First, you need to render the word pretty onto a white background. The command will be something like this:
convert -background white -fill black -font Times -pointsize 14 label:pretty word.png
Result:
Then perform a normalised cross-correlation using Fred Weinhaus's script from here like this:
normcrosscorr -p word.png scan.png correlation-result.png
Match Coords: (504,30) And Score In Range 0 to 1: (0.999803)
and you can see the coordinates of the match are 504,30.
Result:
Another Idea
Another idea might be to take Google's Tesseract-OCR and replace the standard dictionary with the text file containing the words on the page you are processing...

Automating bucket fill actions on transparent layer in GIMP

Using GIMP, I am attempting to generate a large number of the same image but with different colors. In order to preserve the "shadowing", I am using the below steps. These steps get me exactly what I want in the end. The problem is, it's very tedious repeating them by hand over and over. There has to be a better way.
GIMP's batch scripting seems a little daunting, so I'm hoping to get some suggestions on how to automate this. Basically, what would be nice, is I'd like to essentially specify an array or list of colors...and then "automagically" perform the steps below to generate the output with the desired color.
Steps I'm doing by hand...
1.) Load a base PNG file that has an alpha channel.
2.) Add a new transparent layer.
3.) Activate the layer.
4.) Change mode to "multiply".
Then, for a range of different colors, I do the following...
5.) Select a foreground color.
6.) Apply bucket fill (fill similar colors, fill transparent areas, default threshold, fill by composite).
7.) Save the new PNG.
8.) Go to Step #5.
Here's kind of a cheesy representation of the effect I'm trying to achieve...
I'm also open to other non-GIMP suggestions as well.
Thanks for any and all help and suggestions.
I can offer you a nice Javascript example that do this.
try:
https://stackoverflow.com/a/9304367/1726419
there is a link there that actually do what you wand in JS - you can translate it to many other languages...

Resources