fist off, if there is an exchange place more suitable for the question, please address me.
I'm designing some labels in gimp.
I created a A4 300dpi document and created the artwork, arranged them to use all the page. To measure the labels I create a rectangle with the "rectangle selection tool" and there one can inspect the size in cm:
I printed straight from gimp and to my surprise, the printed labels where smaller than designed. I assumed somehow someone along the line added margins to my already A4 document..
I tried saving to PDF and then printing the PDF, very similar results.
I'd say the difference is around 5%
What would be the appropriated method for printing exactly at the size I created the document ignoring any margins ??
I'm using Windows 10, HP ENVY 5010 and Gimp 2.10
I'm printing some pdf's using Ghostscript.NET
this is my config.
List<string> switches = new List<string>
{
"-empty",
"-dPrinted",
"-dFirstPage=1",
"-dLastPage=1",
"-dPrinted",
"-dBATCH",
"-dNOPAUSE",
"-dNOSAFER",
"-dNumCopies=1",
"-sDEVICE=mswinpr2",
#"-sFONTPATH=" + System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts),
"-sOutputFile=%printer%" + printQueue.FullName,
"-f",
inputFile
};
It works pretty well but my paper size is a custom paper 6.5in x 8.5in, my problem is when I print silent to my ricoh printer, try to print in letter.
How can i do to set my paper size in my switches or force the printer to render it properly.
If i print manually must select the paper and bin manually and all print's perfect.
The mswinpr2 device uses Windows to do the printing, in particular the media size is set by the printer canvas.
So the answer is to set the default media selection of your printer to the required media size before you start printing.
You can set the paper size with "-sPAPERSIZE=a4" you can see Paper sizes known to Ghostscript.
or you can set it by height and width
"-dDEVICEWIDTHPOINTS=w"
"-dDEVICEHEIGHTPOINTS=h"
Where w be the desired paper width and h be the desired paper height in points (units of 1/72 of an inch).
I am running a self written script which plots and saves a large number (over 100) of graphs and I have set the axis text to 18pt using
set(0,'defaultAxesFontSize',18);
The figures are saved as .fig using the savefig() command and the font size is correct. But when I save them as .jpg (to be included in a LaTeX report) using print(name, '-djpeg') the font size is the regular default size (guessing about 10pt). If I open one of the .fig files and do File > Save as, the resulting .jpg file has the desired font size.
How can I solve this in the command line?
EDIT:
I have tried using saveas(gcf, name, 'jpg') as well but the result is the same.
EDIT 2:
Here is a minimal example
set(0,'defaultAxesFontSize',18);
x = linspace(0, 2*pi);
plot(x, sin(x))
title('Sine')
xlabel('x')
ylabel('y')
legend('y = sin(x)')
fig = strcat('Sine')
savefig(fig)
print(fig, '-djpeg')
Tanks
Kajsa
I needed to set the paper position mode to auto to make the print the same size as the figure on screen.
This does that for all figures
set(0,'defaultAxesFontSize',18);
set(0,'DefaultFigurePaperPositionMode','auto')
x = linspace(0, 2*pi);
figure(1)
plot(x, sin(x))
title('Sine')
xlabel('x')
ylabel('y')
legend('y = sin(x)')
fig = strcat('Sine')
savefig(fig)
print(fig, '-djpeg')
Works great.
I've got a problem converting a pdflatex-generated PDF image to a PNG image using the standalone package.
The pixelated rendering of the text in the converted image (PDF->PS->PNG via gs and ImageMagick?) is awfully blurry and inferior in quality (sharpness, crispness etc.) to the screen-dumped original PDF.
I have checked out these StackExchange posts:
Standalone diagrams with TikZ?
TikZ to non-PDF
and been guided in the setup of my workflow by the standalone package manual. But after considerable experimental adjustment of the various conversion settings in the code below, I have been unable to improve the quality of the outputted PNG image.
A sample of the settings I have played with:
density (increase the dpi)
size (increase/decrease the dimensions)
the TikZ picture width/height dimensions (no optimum found, but if too small the PNG image width does not equal that specified among the documentclass parameters)
using the command={} option, I have also played with options such as -quality and - set colorspace RGB (though I didn't really know what I was doing here)
Another approach I have taken is to try to set the TikZ picture width and height dimensions (in cm) in such a way that they agree with the conversion dimensions given among the documentclass parameters (using a dpi + pixels -> cm converter).
None of this worked! So any help in converting from PDF to PNG using the standalone package that preserves the sharpness and crispness of the rendered text in the image would be hugely appreciated.
For reference the versions of the various systems/applications I'm using are:
Windows 7
MiKTeX 2.9
TeXnicCenter
gs 9.09
ImageMagick 6.8.6 Q16 (32-bit)
standalone package installed using MiKTeX package manager late Aug 2013
\documentclass[preview,convert={density=300,size=900x300,outext=.png}]{standalone}
\usepackage{tikz}
\usepackage{pgf}
\usepackage{pgfplots}
\begin{document}
\pgfplotsset{every x tick label/.style={at={(1,0)}, yshift=-0.15cm, xshift=-0.0cm, inner sep=0pt, font=\normalsize}}
\begin{tikzpicture}
\begin{axis}[
no markers, domain=-2.1*pi:2.1*pi, samples=1000,
width=30.0cm,
height=10.0cm,
axis x line*=middle,
x axis line style={densely dotted, opacity=0.75},
axis y line*=middle,
y axis line style={densely dotted, opacity=0.75},
ymin=-1.1,
ymax=1.1,
xtick={-6.28318530717959, -5.65486677646163, -5.02654824574367, -4.71238898038469, -4.39822971502571, -3.76991118430775, -3.14159265358979, -2.51327412287183, -1.88495559215388, -1.5707963267949, -1.25663706143592, -0.628318530717959, 0, 0.628318530717959, 1.25663706143592, 1.5707963267949, 1.88495559215388, 2.51327412287183, 3.14159265358979, 3.76991118430775, 4.39822971502571, 4.71238898038469, 5.02654824574367, 5.65486677646163, 6.28318530717959},
xticklabels={$-2\pi$, $-\frac{9\pi}{5}$, $-\frac{8\pi}{5}$, $-\frac{3\pi}{2}$, $-\frac{7\pi}{5}$, $-\frac{6\pi}{5}$, $-\pi$, $-\frac{4\pi}{5}$, $-\frac{3\pi}{5}$, $-\frac{\pi}{2}$, $-\frac{2\pi}{5}$, $-\frac{\pi}{5}$, $0$, $\frac{\pi}{5}$, $\frac{2\pi}{5}$, $\frac{\pi}{2}$, $\frac{3\pi}{5}$, $\frac{4\pi}{5}$, $\pi$, $\frac{6\pi}{5}$, $\frac{7\pi}{5}$, $\frac{\pi}{2}$, $\frac{8\pi}{5}$, $\frac{9\pi}{5}$, $2\pi$},
ytick=\empty,
enlargelimits=false, clip=true, axis on top]
\addplot [line width=0.5,cyan!50!black] {sin(deg(5*x))*cos(deg(x)};
\end{axis}
\end{tikzpicture}
\end{document}
In order to investigate this problem I first created a PDF from your posted tikz/tex code (after copying it into a tikz.tex file):
pdflatex tikz.tex
pdflatex tikz.tex
The resulting PDF does contain the illustration as a vector graphic, not a raster image. Hence, pdfimages -list will NOT detect it.
Then I tested two ways to convert the resulting PDF file to a PNG:
Using ImageMagick's convert (which employs Ghostscript behind your back as a 'delegate' to process the PDF input)
Using Ghostscript directly
1. Using convertwith -density 720
I've used this command to create a PNG from the PDF:
convert -density 720 tikz.pdf tikz1.png
Here is the result:
Why did I use -density 720? Because 720 PPI is the default resolution which Ghostscript uses when creating PDFs (unless you override this default setting by providing your own via -rNxM on the gs command line)...
The resulting image has a size of 374 kB (the PDF had 49 kB) and a width x height dimension of 8060 x 2390 pixels. Any pixelization (which will happen whenever you create a PNG!) is not immediately visible at that resolution.
The runtime for a loop running this command 10 times was 47 seconds.
2. Using Ghostscript directly
To achieve the direct PNG conversion with a Ghostscript command I used:
gs -o tikz-gs.png -sDEVICE=pngalpha \
-dAlignToPixels=0 -dGridFitTT=2 \
-dTextAlphaBits=4 -dGraphicsAlphaBits=4 \
tikz.pdf
Here is the resulting PNG:
It's file size is 308 kB, with dimensions of 8060 x 2390 pixels.
The runtime for a loop running this command 10 times was 17 seconds.
Analysis
PDF input file: Sizes of components
After looking at the source code of the PDF file after uncompressing all objects, I came up with the following statistics:
Total size of 5 embedded Type1 fonts................................ 38615 Bytes
Total size of v`/Contents` stream (mainly used by vector drawing)... 32630 Bytes
Rest of PDF structure ("overhead", if you want)..................... 5827 Bytes
---------------------------------------------------------------------------------
Total size of PDF (after uncompressing objects)..................... 77072 Bytes
The fonts are Type 1 (i.e. PostScript) fonts, according to the output of pdffonts. They are all embedded as subsets:
pdffonts tikz.pdf
name type encoding emb sub uni object ID
-------------------------- ------------ ---------------- --- --- --- ---------
FXXUVH+CMSY10 Type 1 Builtin yes yes no 7 0
BCSIZL+CMR10 Type 1 Builtin yes yes no 8 0
SFJZUV+CMMI10 Type 1 Builtin yes yes no 9 0
WPSSUY+CMR7 Type 1 Builtin yes yes no 10 0
SYHYOI+CMMI7 Type 1 Builtin yes yes no 11 0
Because...
...Fonts (unless they are raster fonts) are a different way to very efficiently code vector shapes for glyphs depicting text characters,
...Fonts + Vector drawing compose more than 90% of the total PDF size,
...there is no way in hell that lets you create a PNG raster image from the (compressed) PDF sized 49 kB (uncompressed size was 75 kB) that isn't larger by a few times than the original PDF file if you want to avoid directly visible "pixelization" and "blur".
Even if you use a resolution of 720 PPI (which creates a 308 kB-sized PNG), you'll still see pixelization once you start zooming in. Such pixelization does not occur with the PDF (because all its shapes are defined as vectors).
The following three images are screenshots:
top, from the tikz.pdf file at a high zoom level (~1000%),
center, from the tikz.png created with 720 PPI (at a similar zoom level),
bottom, from the tikz72.png created with 72 PPI (at a similar zoom level):
The text sizes used for the annotation of the coordinate axis are only around 10 points. If you rasterize those, you'll get clearly visible pixelization at any resolution below 400 PPI, maybe even above...
My Ghostscript is a self-compiled 9.17 GIT PRERELEASE. My ImageMagick is 6.9.0-0 Q16 x86_64.
Ive got Dymo labelwriter 400. It works like a charm with a glabels on ubuntu. I am currently writing software to create automatic labels. for that I need to know the size of the png I want to print.
The paper I use is: Large Address, which is 89x36mm.
When I create and print such an image it is not taking the whole label. It is in fact 2/3 of the label size.
In ppd I found such thing:
*PageSize w102h252/30321 Large Address: "<</PageSize[102 252]/ImagingBBox null>>setpagedevice"
I imagine 102 252 is a size. I created such png in gimp, still is too small.
How can I determine what size should the image have to fit the label?
The size will be in points (72nds of an inch). For example, 8.5 x 11 (letter) size paper is shown as
<</PageSize[ 612 792 ] /ImagingBBox null>>setpagedevice
102 = 1.4 inches or 36mm
252 = 2.5 inches or 89mm