Ghostscript: Convert CMYK Color to solid color with specific name - ghostscript

is it possible to convert specific cmyk colors in pdf generation process?
In my case I have simulated colors for the customer like for example gold with value C15 M30 Y70 K20. This color must be replaced for the printer who uses a real gold foil. There for the CMYK value must be changed to C0 M100 Y0 K0 as well as the color must be a solid color instead of process color and last but not least it must get a specific color name. In this case „goldfoil“.
So can ghost script look for the specific CMYK values and replace them?
Any hint would be very helpful

No, you can't have Ghostscript alter colour values like that.
The correct way to do this is to create the PostScript program with a /Separation colour space, and define the alternate as a CMYK space with specific CMYK values to be used when the ink is not supported.
When the pritner supports the named ink 'goldfoil' it will print using the Gold ink (or foil in your case), when the named ink is not supported the printer will use the alternate space and colour values. That lets your customer see an approximation of the result on a CMYK printer, but your printer will be able to produce the true gold output.

I talked to the developer. The generated file is an svg that will be converted to PDF. I am not sure if this is here the right place but maybe you can give me some input. What I found out so far is that SVG is supporting ICC Profiles. So I thought to link an ICC profile and give the color the special name like so:
<color-profile name=„ISOcoated_v2_eci" xlink:href="http://swatches.example.com/ISOcoated_v2_eci.icc"/>
<circle fill=„#9C9475 icc-color(ISOcoated_v2_eci, Goldfolie"/>
Also the correct cmyk values are missing so can I combine it like so?
<color-profile name=„ISOcoated_v2_eci" xlink:href="http://swatches.example.com/ISOcoated_v2_eci.icc"/>
<circle fill=„#9C9475 device-cmyk(0.00, 1.00, 0.00, 0.00) icc-color(ISOcoated_v2_eci, Goldfolie "/>
or so?
<color-profile name=„ISOcoated_v2_eci" xlink:href="http://swatches.example.com/ISOcoated_v2_eci.icc"/>
<circle fill=„#9C9475 icc-color(ISOcoated_v2_eci,0.00, 1.00, 0.00, 0.00) icc-color(ISOcoated_v2_eci, Goldfolie "/>

Related

Sass color transform calculation

I have two shades of the color blue (#1E95EF -> #1988DD), and need to figure out the color transformation that has happened in order to replicate it across other colors in my palette (red, green etc).
I've used combinations of darken()/lighten() & saturate()/desaturate() to eyeball the transformation, and have gotten it pretty close:
desaturate(darken(#1E95EF, 4.5%), 8%); === #1A88DC
But I need to get it exactly right, so that the small errors that I make with the percentage decimal points are not replicated across all of the colors. How can I figure out exactly what transformation has occurred?
Here is what I've tried:
sassmeister gist
In this snippet, the relevant classes to my example are .ga-primary and .ga-primary-hover
You can measure the differences between colors in different ways, depending on the color model/space you're using. Hex colors use RGB, but the HSL model will be more useful here. It records a color as 3 values: Hue, Saturation and Lightness.
We can use SASS's HSL functions to work out how each value of the color differs, and then selectively apply that difference to other colors:
$start-color: #1E95EF
$end-color: #1988DD
//We won't need the hue-difference in practice
$hue-difference: hue($start-color) - hue($end-color)
//These express the difference as a percentage
$saturation-difference: saturation($start-color) - saturation($end-color)
$lightness-difference: lightness($start-color) - lightness($end-color)
#function color-adjust($base-color)
//Apply the lightness and saturation changes but keep the original Hue
#return hsl(hue($base-color), saturation($base-color) + $saturation-difference, lightness($base-color) + $lightness-difference)
//To find the adjusted color, just pass whatever base color you like to the color-adjust function:
background: color-adjust(red)
Here's a demo with a few colors: http://codepen.io/anon/pen/bqOaZZ
Obviously that code can be compacted a lot - I'm thinking that what you really want is to define your variants as a set of Saturation/Lightness changes, and then apply them to your whole palette (rather than trying to 'reverse-engineer' it from one example pair). If you want help with something to do that, let me know!

How can I split an image into multiple files with an action in photoshop?

I use Stamps.com to print shipping labels that are 2.4" wide. Stamps.com unfortunately will only generate a pdf of this size label with 4 labels on the sheet. It is not paginated, and will not print sequentially. Their template assumes you will print it out on an 8.5" x 11" label sheet and peel off from there. Four Label 8.5x`11 sheet
I want to print on a thermal, continuous roll printer which cuts each label out automatically. To have this work I need each label to be one page, and the pdf with four labels split into four cropped files of 2.4" x 8.5". Any ideas?
I have failed so far in making an action in both acrobat, and photoshop. Should I be looking into solving this programmatically outside of photoshop?
I would be inclined to do that with ImageMagick which is installed on most Linux distros and is available for OSX and Windows.
Unfortunately, you haven't provided a sensible sample image, so I'll provide a fake one. I have made the border yellow intentionally so you can see it on StackOverflow's white page layout.
Just at the command line in the Terminal, you would want to set the default density so that when ImageMagick rasterises the image it retains its quality. The [0] refers to the first page of the PDF. Then you would want to trim off the border - whatever colour it is (+/- a small fuzz factor to allow for variations in image encoding) and then tile into 4 equal horizontal strips. So, your command would be:
convert -density 240 stamps.pdf[0] fuzz 20% -trim -crop x4# f-%d.jpg
and you will get 4 files out, called f-0.jpg, f-1.jpg, f-2.jpg and f-3.jpg

Matlab gui image incorrectly blue

I am creating a GUI containing an image using the following code:
try
Imagenamehere = imread('Imagenamehere.jpg');
axes(handles.Logo)
image(Imagenamehere)
set(gca,'xtick',[],'ytick',[])
catch
msgbox('Please download all contents from the zipped file into working directory.')
end
The image shows up but for some reason is completely coloured blue as if put through a blue filter. I don't think it would be wise to upload the image but it is a simple logo coloured black and white.
Anyone know what could be causing this?
Check the size, type (probably uint8) and range of your image. It sounds like for some reason your images are being displayed with colormap as jet (the default), and possibly also that your range is not what MATLAB expects (e.g. 0 to 1 not 0 to 255), resulting in all your values being relatively low (blue on the jet colormap).
"black and white" is just one way of interpreting an image file which contains only two colors. MATLAB makes several assumptions when you pass data into a display function like image. If you don't specify colormap and image data range, it will make a guess based off things like data type.
One possibility is that your logo file is an indexed image. In these cases you need to do:
[Imagenamehere map] = imread('Imagenamehere.jpg');
colormap(map);

Matplotlib Plots Lose Transparency When Saving as .ps/.eps

I'm having an issue with attempting to save some plots with transparent ellipsoids on them if I attempt to save them with .ps/.eps extensions.
Here's the plot saved as a .png:
If I choose to save it as a .ps/.eps here is what it looks like:
How I got around this, was to use ImageMagick to convert the original png to a ps. The only problem is that the image in png format is about 90k, and it becomes just under 4M after conversion. This is not good since I have a lot of these images, and it will take too much time to compile my latex document. Does anyone have a solution to this?
The problem is that eps does not support transparencies natively.
There are few options:
rasterize the image and embed in a eps file (like #Molly suggests) or exporting to pdf and converting with some external tool (like gs) (which usually relies as well on rasterization)
'mimic' transparency, giving a colour that looks like the transparent one on a given background.
I discussed this for sure once on the matplotlib mailing list, and I got the suggestion to rasterize, which is not feasible as you get either pixellized or huge figures. And they don't scale very nicely when put into, e.g., a publication.
I personally use the second approach, and although not ideal, I found it good enough. I wrote a small python script that implements the algorithm from this SO post to obtain a solid RGB representation of a colour with a give transparency
EDIT
In the specific case of your plot try to use the zorder keyword to order the parts plotted. Try to use zorder=10 for the blue ellipse, zorder=11 for the green and zorder=12 for the hexbins.
This way the blue should be below everything, then the green ellipse and finally the hexbins. And the plot should be readable also with solid colors. And if you like the shades of blue and green that you have in png, you can try to play with mimic_alpha.py.
EDIT 2
If you are 100% sure that you have to use eps, there are a couple of workarounds that come to my mind (and that are definitely uglier than your plot):
Just draw the ellipse borders on top of the hexbins.
Get centre and amplitude of each hexagon, (possibly discard all zero bins) and make a scatter plot using the same colour map as in hexbin and adjusting the marker size and shape as you like. You might want to redraw the ellipses borders on top of that
Another alternative would be to save them to pdf
savefig('myfigure.pdf')
That works with pdflatex, if that was the reason why you needed to use eps and not svg.
You can rasterize the figure before saving it to preserve transparency in the eps file:
ax.set_rasterized(True)
plt.savefig('rasterized_fig.eps')
I had the same problem. To avoid rasterizing, you can save the image as a pdf and then run (on unixish systems at least) in a terminal:
pdftops -eps my.pdf my.eps
Which gives a .eps file as output.
I solved this by:
1) adding a set_rasterization_zorder(1) when defining the figure area:
fxsize=16
fysize=8
f = figure(num=None, figsize=(fxsize, fysize), dpi=180, facecolor='w',
edgecolor='k')
plt.subplots_adjust(
left = (18/25.4)/fxsize,
bottom = (13/25.4)/fysize,
right = 1 - (8/25.4)/fxsize,
top = 1 - (8/25.4)/fysize)
subplots_adjust(hspace=0,wspace=0.1)
#f.suptitle('An overall title', size=20)
gs0 = gridspec.GridSpec(1, 2)
gs11 = gridspec.GridSpecFromSubplotSpec(1, 1, subplot_spec=gs0[0])
ax110 = plt.Subplot(f, gs11[0,0])
f.add_subplot(ax110)
ax110.set_rasterization_zorder(1)
2) a zorder=0 in each alpha=anynumber in the plot:
ax110.scatter(xs1,ys1 , marker='o', color='gray' , s=1.5,zorder=0,alpha=0.3)#, label=label_bg)
and
3) finally a rasterized=True when saving:
P.savefig(str(PLOTFILENAME)+'.eps', rasterized=True)
Note that this may not work as expected with the transparent keyword to savefig because an RGBA colour with alpha<1 on transparent background will be rendered the same as the RGB colour with alpha=1.
As mentioned above, the best and easiest choice (if you do not want to loose resolution) is to rasterized the figure
f = plt.figure()
f.set_rasterized(True)
ax = f.add_subplot(111)
ax.set_rasterized(True)
f.savefig('figure_name.eps',rasterized=True,dpi=300)
This way, you can manage the size by dpi option as well. In fact, you can also play with the zorder below you want to apply the rasterization:
ax.set_rasterization_zorder(0)
Note: It is important to keep f.set_rasterized(True) when you use plt.subplot and plt.subplot2grid functions. Otherwise, label and tick area will not appear in the .eps file
My solution is to export the plot as .eps, load it up to Inkscape for example, then Ungroup the plot, select the object that I want to set the transparency and just edit the Opacity of the Fill in the "Fill and Stroke" tab.
You can save the file as .svg if you want to tweak it later, or export the image for a publication.
If you are writing the academic paper in latex, I would recommend you export the .pdf file rather than .eps. The .pdf format supports transparency perfectly and has good compression efficiency, and most importantly, can be easily edited in Adobe Illustrator.
If you wanna further edit the graph (NOT EDITING DATA! I MEAN, FOR GOOD-LOOKING), you could open the exported graph, in Adobe Acrobat - Edit - Copy elements into Adobe Illustrator. The two software can handle everything perfectly.
I work happily with this method. Everything clear, editable and small-size. Hope can help.

What is the format of Xlib ZPixmap format

does anyone know what is XLib ZPixmap format for 32/24bit images/pixmaps. Is it RGB(A) or BGR(A), etc. or highly implementation dependent?
Pixmaps have no color, period. They're just arrays of pixel values. The only drawables in X that have a color interpretation are Windows (channels defined by Visuals), Pictures (channels defined by Picture Formats), and GLX drawables (channels defined by either a GLX visual or an fbconfig). Any "color" interpretation you want to put on a pixmap is a function of where those pixels are going to end up (or, where they came from). If you're going to put them into a Window, look at the Visual of the Window to discover what the color channel masks are.
[edit: added GLX drawable info]

Resources