Identify nonselectable image from PDF - python

I need to identify (but not extract) nonselectable image from PDF. I went through the thread 'Extract images from PDF without resampling, in python?' but didn't get a solution. If I'm correct, PyMuPDF can only identify the selectable images (when you click it the image gets shade). Please refer to the line chart in 61899345.pdf in the link as an example of nonselectable image. Because I have a large number of such files to process, I guess I have to find a rule to define an image. Thank you.

Related

How to add a signature into a specific field in a PDF document using Python?

I tried adding an image into a PDF in a specific field in a particular position,
I also referred to another post in the community (How to add image to PDF file in Python?),
This code allows us to overlay the entire Image over PDF, but we want to insert the image in a particular position of a PDF.
Thanks in advance for the Leads.

How to extract only ID photo from CV with pdfimages

Hi I tried to use pdfimages to extract ID images from my pdf resume files. However for some files they return also the icon, table lines, border images which are totally irrelevant.
Is there anyway I can limit it to only extract person photo? I am thinking if we can define a certain size constraints on the output?
You need a way of differentiating images found in the PDF in order to extract the ones of interest.
I believe you have the options of considering:
Image characteristics such as Width, Height, Bits Per Component, ColorSpace
Metadata information about the image (e.g. a XMP tag of interest)
Facial recognition of the person in the photo or Form recognition of the structure of the ID itself.
Extracting all of the images and then use some image processing code to analyze the images to identify the ones of interest.
I think 2) may be the most reliable method if the author of the PDF included such information with the photo IDs. 3) may be difficult to implement and get a reliable result from consistently. 1) will only work if that is a reliable means of identifying such photo IDs for your PDF documents.
Then you could key off of that information using your extraction tool (if it lets you do that). Otherwise you would need to write your own extraction tool using a PDF library.

Rotated Image Orientation of Cellphone Pictures

I'm trying to display images on a simple html page, but it looks as though the image orientation of many of my pictures are rotated to the left, because they were taken by cellphone. The images are hosted on my computer.
I tried the css property image-orientation: from-image; but to no avail.
I used python's piexif library as well as PIL library to strip EXIF data, but the new stripped images still are rotated to the left.
I really feel as if there should be some simpler, standardized method of neutralizing the orientation of all of my images so that they naturally display upright?
Rotate and remove 'Orientation' of exif value.
http://piexif.readthedocs.io/en/latest/sample.html#rotate-image-by-exif-orientation

Color in image gets dull after saving it in OpenCV

I am using opencv module to read and write the image. here is the code and below is the image i am reading and second image is after saving it on disk using cv2.imwrite().
import cv2
img = cv2.imread('originalImage.jpg')
cv2.imwrite('test.jpg',img)
It is significantly visible that colors are dull in second image. Is there any workaround to this problem or I am missing on some sort of setting parameters..?
I have done a bit of research on the point #mark raised about ICC profile. I have figured out a way to handle this in python PIL module. here is the code that worked for me. I have also learned to use PNG file format rather JPEG to do lossless conversion.
import Image
img = Image.open('originalImage.jpg')
img.save('test.jpg',icc_profile=img.info.get('icc_profile'))
I hope this will help others as well.
The difference is that the initial image (on the left in the diagram) has an attached ICC profile whereas the second one (on the right) does not.
I obtained the above image by running the ImageMagick utility called identify like this:
identify -verbose first.jpg > 1.txt
identify -verbose second.jpg > 2.txt
Then I ran the brilliant opendiff tool (which is part of macOS) like this:
opendiff [12].txt
You can extract the ICC profile from the first image also with ImageMagick like this:
convert first.jpg profile.icc
Your first input image has some icc-Profile associated in the meta-data, which is an optional attribute and most devices may not inject it in the first place. The ICC profile basically performs a sort of color correction, and the correction coefficients are calculated for each unique device during calibration.
Modern Web Browsers, Image Viewing utilities mainly take into account this ICC profile information before rendering the image onto the screen, that is the reason why there is a diff in both the images.
But Unfortunately OpenCV doesn't reads the ICC config from the meta data of the image to perform any color correction.

how to test for a specific watermark in an image with python2.7

there is this project am currently working on, which requires me to watermark every uploaded image. i have tried series of examples online, but they are not giving me what i really want as result
for example
i have an image A with image B watermarked on it, the two images are of the same dimensions. i applied opacity of 0.5 on image B before placing it on image A
now, i would really appreciate if anyone could help with a boolean function to check if image A has already been watermarked with image B before watermarking it.
thanks.
This depends on several factors that you'll need to provide more information for.
For instance, how complex are these images? Is there a lot of noise? Are the images that are uploaded similar in any way, or are they heterogenous? Are the watermarks always the same, or are they different?
As a general principle for extracting objects from images, you should look into processes such as color deconvolution, thresholding, and blob extraction.
In short--some sample images would go a long way...
yeah, finally found a dubious way to solve the problem, by hiding a specific text on the alpha layer of the image after watermarking it using steganography.
so on every upload, i get the image, iterate through the lowest pixels of the image's alpha layer, then compare the result to the text. if the result matches the text, definitely, the image has been watermarked.

Categories

Resources