Ghostscript - Layers and Transparency - pdf

I have a pdf which (it seems) has multiple layers. In the background is a form, and above is a layer with the handwritten signature, comments and so on. I think its scanned - I can't provide it because it is a trustworthy document.
Using Ghostscript 9.56.1 with the PDFA.ps and transparency.ps from the Page and the command:
switches.Add("-dQUIET");
switches.Add("-dSAFER");
switches.Add("-dPDFA=1");
switches.Add("-q");
switches.Add("-dBATCH");
switches.Add("-sPAPERSIZE=a4");
switches.Add("-dNOPAUSE");
switches.Add("-sColorConversionStrategy=UseDeviceIndependentColor");
switches.Add("-sDEVICE=pdfwrite");
switches.Add("-dALLOWPSTRANSPARENCY");
switches.Add($"--permit-file-read={iccPath}");
switches.Add($"-sPDFAICCProfile={iccPath}");
switches.Add("-dPDFACompatibilityPolicy=2");
switches.Add("-dNOPROMPT");
....// ps files, input - output...
I have the problem that the transparency part of the hand-written layer is rendered white and so the background (in this case the form/text) is hidden. Is it somehow possible with java (e.g. pdfbox) or Ghostscript directly to flatten the layers, keeping the transparency of the top layer to avoid hiding the text in the bottom layer?

Related

Vector graphics artefacts: saving Powerpoint graphics to PDF results in blurred pixels

I have used Powerpoint 2016 to create a complex plot, based on an imported EMF graph saved from Matlab and some line drawings added in Powerpoint. I would like to save the entire contents of the Powerpoint slide as a PDF or EPS file, so as to have the figure as zoomable (as vector graphics).
Selecting the entire slide contents and right-clicking SavePictureAs only gives me EMF as the only vector graphics option, so instead I saved the entire presentation (consisting of a single slide) as a PDF. However, several parts of the image (those that were imported as a vector graphics EMF from Matlab) appear blurred in the saved PDF:
.. even though they look fine when viewed in Powerpoint:
Here is another example of a figure that looks fine in Powerpoint but blurred when saved as PDF:
I also tried some online converters to go from EMF (which Powerpoint can save into) to either PDF or EPS, but each of those produce its own type of artefact.
Can anyone suggest a solution to save this Powerpoint content into an artefact-free PDF or EPS file?
z8080 and I have been following up on this in Microsoft Answers' PowerPoint forum, but I thought I'd come back and fill in what we've learned.
In the second example above, the grid is actually not vector graphics. It's a 7x7 pixel image. Each of the squares in the grid is actually a single pixel, blown WAY up.
Problem is, when PowerPoint prints/saves as PDF, it wants to "help" by antialiasing and upscaling the image to eliminate the jaggies. With most ordinary photos, this is usually A Good Thing. In this case, not.
To make matters worse, the slide size of z8080's presentation is quite large, which seems to cause PPT to upscale to a much larger number of pixels than it ordinarily would. I found that if I created a new presentation at the normal default slide size and pasted the graphic from z8080's presentation into it, the resulting PDF looked much more like the original slide, as expected.

Blend pixels on .net core

I am trying to overlay a part of one image on top of another image on .net core (code needs to be cross platform).
I considered using ImageSharp since it supports win,mac and linux.
But i couldn't find pixel blending on their features list, although i saw that you can access an individual pixel.
So the use case would be, i have two 4k Png images and i want a small part of the first image (roughly 10% square of the overall image) to be overlayed on top of the second image (but not the whole image just the same 10% space) and get the area where the merging happened as a new Jpeg image.
(the source PNGs have some degree of transparancy).
I considered cropping out the two parts i want to merge from the two 4k images and then blending them to get the final image, but that is slow for the needs of the project I'm working on.
ImageSharp does support pixel blending, you can specify the pixel blending mode during Draw/Fill operations by passing in an GraphicsOptions parameter and setting its BlenderMode and BlendPercentage(defaults to 100%) properties.
Currently ImageSharp has implementations for the following blending modes:
Normal
Multiply
Add
Substract
Screen
Darken
Lighten
Overlay
HardLight
Src
Atop
Over
In
Out
Dest
DestAtop
DestOver
DestIn
DestOut
Clear
Xor

How does e commerce Websites edit their product pic for showing on front

I am Wounding How these e commerce Website Edit their product pic for the front page
for example
This is an product image from flipkart.com an online store
This is Photo Taken by the camera
In Picture 1: There is Some blur effect how did they do it
There's no effect used. It is just a simple process.
The object is photographed against a white background.
The image is then 'masked' to isolate the object on it's own layer, either by hand or by a photoshop plugin. Manually, you can draw around the edge of the object using the lasso tool, then add a layer mask to remove the background.
Noise reduction, colour correction and other retouches are applied to this object layer. This is the blur effect that I think you are referring to. This may or may not be required, depending on image quality.
Shadows tend to be redrawn by hand using simple shapes with various blurs applied on a layer below the object. The simplest shadow is just a black ellipse with gaussian blur applied and layer opacity set to 20%.
A background colour is then applied, depending on how you will place the image. With images for E-Commerce this tends to be a white background.
The process for masking is varied and depends on your preferred tools, the complexity of the image and the shadow realism you want to achieve.
I recommend further research into 'Image Masking' to find the technique that suits you.

What’s the difference between rasterization and rendering?

Can anybody explain how rendering differs from rasterization especially in the context of font rendering (why not font rasterization)?
Can rendering be called a special technique (like greyscale rendering and subpixel rendering) before the rasterizer rasterizes the image?
Rendering is a broad term that generally means transforming computer-readable information, for example objects in a 3d scene, to one or more images.
Rasterization is a more specific term that typically means the process of transforming a vector (curve based) image to a rasterized (pixel based) image.
Rendering involves performing the calculations for vectors and shape geometry for the elements to be drawn.
Rasterizing involves converting the rendered vectors and shapes into pixel bit maps for display.

Is it possible to remove the background of a text block in pdf using ghostscript

I am trying to convert a pdf into tif using ghost script. Is it possible to remove the background (grey color) of a text block (back font color) in a pdf using ghost script? I would like to replace the grey background to white.
Appreciate your help!!
I don't think you'll get a generic solution to your problem because there are many different ways such a background may be coded in your PDF and there is no sure way to distinguish such a background from a rectangular form of some vector image.
PDF essentially offers a set of tools for positioning glyphs and vector graphics in some rectangle (page) to display and some additional tools to add some interactivity (e.g. forms). Thus, a colored background in a PDF generally is created by drawing a line along the edge of the area of the background, fill this form with the desired color, and position glyphs and graphics (text and images) atop it. There are other operators, too, which can be used, though, and many variants of their use, and generally the form created is not marked as background.
In the answer Dingo refers to in his comment a rectangle covering the whole page, actually even a bit more (in case of a fairly common choice of a media box), is drawn (m: move to a corner; 4*l: draw the 4 edge lines; h: close the path; f fill the form).
Thus, please make the PDF in question available for inspection, maybe there is some specific solution for your file.