setupexternalfigures and resoĺution
Hi, what is resolution meant to do? Whatever I insert as resolution, I get no change. \setupexternalfigure[location={default,local},resolution=30] \starttext \externalfigure[hacker] \stoptext What am I missing? TIA juh
Am 01.09.22 um 10:44 schrieb juh+ntg-context--- via ntg-context:
Hi,
what is resolution meant to do?
Whatever I insert as resolution, I get no change.
\setupexternalfigure[location={default,local},resolution=30] \starttext \externalfigure[hacker] \stoptext
What am I missing?
The resolution parameter is still not used by default ConTeXt, sorry. But you can use it with the attached lua file like: \loadluafile[grph-downsample] \doifmodeelse{print}{% \def\Resolution{300} }{% \def\Resolution{96} }% \setupexternalfigures[ %directory={./Logos,img}, conversion=lowres.jpg, resolution=\Resolution, ] Hraban
Am 01.09.22 um 10:51 schrieb Henning Hraban Ramm via ntg-context:
Am 01.09.22 um 10:44 schrieb juh+ntg-context--- via ntg-context:
Hi,
what is resolution meant to do?
What am I missing?
The resolution parameter is still not used by default ConTeXt, sorry.
But you can use it with the attached lua file like:
This works also: \startluacode local function downsampler(oldname, newname, resolution) if not resolution or resolution == "" then resolution = 72 end local cmd = string.format( [[gm convert -resample %ix%i %s %s]], resolution, resolution, oldname, newname) os.execute(cmd) end -- Set the PDF and default JPEG converters to the above function. figures.converters.jpg.pdf = downsampler figures.converters.jpg.default = downsampler \stopluacode I didn’t manage to plug this into the "conversion" mechanism. Hraban
Hi Hraban, Am 01.09.22 um 10:56 schrieb Henning Hraban Ramm via ntg-context:
\startluacode local function downsampler(oldname, newname, resolution) if not resolution or resolution == "" then resolution = 72 end local cmd = string.format( [[gm convert -resample %ix%i %s %s]], resolution, resolution, oldname, newname) os.execute(cmd) end
-- Set the PDF and default JPEG converters to the above function. figures.converters.jpg.pdf = downsampler figures.converters.jpg.default = downsampler \stopluacode
I didn’t manage to plug this into the "conversion" mechanism.
Thanks a lot. With this I get 5.9MB instead of 13MB. Maybe I can skip postprocessing the pdf file with ps2pdf. From an error message I guess that this script also tries to downsample png files. Is that correct? juh
Am 01.09.22 um 12:37 schrieb juh+ntg-context--- via ntg-context:
Hi Hraban,
Am 01.09.22 um 10:56 schrieb Henning Hraban Ramm via ntg-context:
\startluacode local function downsampler(oldname, newname, resolution) if not resolution or resolution == "" then resolution = 72 end local cmd = string.format( [[gm convert -resample %ix%i %s %s]], resolution, resolution, oldname, newname) os.execute(cmd) end
-- Set the PDF and default JPEG converters to the above function. figures.converters.jpg.pdf = downsampler figures.converters.jpg.default = downsampler \stopluacode
I didn’t manage to plug this into the "conversion" mechanism.
Thanks a lot. With this I get 5.9MB instead of 13MB.
Maybe I can skip postprocessing the pdf file with ps2pdf.
From an error message I guess that this script also tries to downsample png files. Is that correct?
According to the sources it should only attack JPEGs. Hraban
Am 01.09.22 um 10:51 schrieb Henning Hraban Ramm via ntg-context:
\loadluafile[grph-downsample] \doifmodeelse{print}{% \def\Resolution{300} }{% \def\Resolution{96} }%
\setupexternalfigures[ %directory={./Logos,img}, conversion=lowres.jpg, resolution=\Resolution, ]
With the script I get strange results. I am not sure whether the resolution is correctly calculated. And I am wondering what the script is doing with png files. juh
Am 01.09.22 um 13:43 schrieb juh+ntg-context--- via ntg-context:
Am 01.09.22 um 10:51 schrieb Henning Hraban Ramm via ntg-context:
\loadluafile[grph-downsample] \doifmodeelse{print}{% \def\Resolution{300} }{% \def\Resolution{96} }%
\setupexternalfigures[ %directory={./Logos,img}, conversion=lowres.jpg, resolution=\Resolution, ]
With the script I get strange results. I am not sure whether the resolution is correctly calculated.
And I am wondering what the script is doing with png files.
This one attacks all images, but it doesn’t calculate the final size correctly. Hraban
Am 01.09.22 um 15:04 schrieb Henning Hraban Ramm via ntg-context:
Am 01.09.22 um 13:43 schrieb juh+ntg-context--- via ntg-context:
Am 01.09.22 um 10:51 schrieb Henning Hraban Ramm via ntg-context:
\loadluafile[grph-downsample] \doifmodeelse{print}{% \def\Resolution{300} }{% \def\Resolution{96} }%
\setupexternalfigures[ %directory={./Logos,img}, conversion=lowres.jpg, resolution=\Resolution, ]
With the script I get strange results. I am not sure whether the resolution is correctly calculated.
And I am wondering what the script is doing with png files.
This one attacks all images, but it doesn’t calculate the final size correctly.
For the records. I need a resolution of 240 to get a good looking image. This is more or less the same quality with 150 using the other possibility. After playing around this day I fear that postprocessing with ps2pdf is more predictable and results in a way more tiny file. juh
Thanks for this code Hraban. I tried this last night and it worked really well. I did have one stumbling block when I noticed that those image files with a space in their names were not found, however renaming without a space solved the problem. Is this a bug or a feature? Thanks Keith McKay On Thu, 1 Sep 2022, 09:52 Henning Hraban Ramm via ntg-context, < ntg-context@ntg.nl> wrote:
Am 01.09.22 um 10:44 schrieb juh+ntg-context--- via ntg-context:
Hi,
what is resolution meant to do?
Whatever I insert as resolution, I get no change.
\setupexternalfigure[location={default,local},resolution=30] \starttext \externalfigure[hacker] \stoptext
What am I missing?
The resolution parameter is still not used by default ConTeXt, sorry.
But you can use it with the attached lua file like:
\loadluafile[grph-downsample] \doifmodeelse{print}{% \def\Resolution{300} }{% \def\Resolution{96} }%
\setupexternalfigures[ %directory={./Logos,img}, conversion=lowres.jpg, resolution=\Resolution, ]
Hraban
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net
___________________________________________________________________________________
Am 02.09.22 um 10:39 schrieb Keith McKay via ntg-context:
Thanks for this code Hraban. I tried this last night and it worked really well. I did have one stumbling block when I noticed that those image files with a space in their names were not found, however renaming without a space solved the problem. Is this a bug or a feature?
The call to gm convert was lacking quoting of the file names. Fixed in attachment. While the code does some downsampling, the calculation is not always right, because it doesn’t consider scaling (or something like that). Hraban
participants (3)
-
Henning Hraban Ramm
-
juh+ntg-context@mailbox.org
-
Keith McKay