| Post Reply | RetroFed Forum Forum Index » Paperless office; document/image processing 📷🮕🖥🖻📠🗄🖼📥🧾 |
| Author | Message | ||
|---|---|---|---|
|
evenwicht
lemmy.sdf.org
evenwicht@lemmy.sdf.org Joined: 2024-07-01 |
I was able to embed an EPS file in the source so that the compiler generates the image that the document re-imports. EPS files have different formats and some of them fail because they are binary, so it’s a dicey process. what workedI started with a large JPG which I was importing this way:
Looked nice but quite wasteful as the whole JPG ends up inside the PDF only to be scaled down to 18mm wide. So I needed to resample it. But I also need to distribute the tex doc and really can’t be dealing with distributing multiple files. EPS files can be simple ascii text and they can be embedded in the code. So I ran ImageMagick to shrink the image and produce an EPS file:
The the scaling option (width=18mm) can now be omitted: I could not be bothered to investigate. So I made the image 50% bigger than needed and made latex rescale it (sloppy but works):
In LaTeX: Job done. But sloppy because I should not have to make the image bigger than displayed and then downscale it in LaTeX to avoid blurr. better, but failsSo I used #GIMP to shrink the image. GIMP is a different kind of shit-show because it crashes Wayland, but I was finally able to scale the image faster than GIMP could crash and GIMP did a good job. That is, the EPS file was the right size and without getting blurry. Thus the resampling was proper. But the EPS file produced by GIMP is not ascii text. It has some characters that fuck up the ability to embed the image in the source code. Fuck me. There are different EPS flavors and even a badly documented Perhaps I have to use GIMP to scale to a PPM and then ImageMagick to convert the PPM to EPS without scaling. Assuming that works, an annoyance remains: an EPS ascii text file from ImageMagick has many lines which requires a lot of scrolling to reach the LaTeX code after it’s embedded in the code. Are there any other non-binary image formats apart from (e)ps? PDF is a one. A PDF can also be binary or ascii. If the effort is made to ensure an ascii PDF, I think the downside is the final document is no longer versatile (can only be PDF not PostScript). SVG is another ascii image format but I’m not confident LaTeX handles it well. I am tempted to follow this approach to make a definitively ascii EPS file. But it would be useful if there were a way to make an EPS file that has no more than 20 or so linefeeds. There is an UpdateI looked more into ImageMagick. The complexity is staggering because there are six approaches to minifiscation: -sample Resizing turns out to serve my purpose well. But then there are 30 different filters listed by
They all looked the same AFAICT and all were decent. So I just used the default filter in the end. I’m glad I could ditch GIMP given how badly it behaves on Wayland. The encoding from ImageMagick is very safe for embedding in LaTeX docs, as it seems to use only HEX symbols (0-9,a-f). Here is a sample:
OTOH, it’s so limited that an image of approximately ~18x25 mm ends up taking almost 1600 lines of text in the document. GIMP’s output is apparently also ascii. I don’t know how to test that other than to grep it for something arbitrary and see if grep prints that the file is binary. The |
||
| 1 Original | |||
| Post Reply |
Back to top |