Installing gifsicle on Cygwin is really easy, which it has to be if I am to do it. The website includes binaries for many platforms (Linux, Windows, even DOS), but not for Cygwin. Because care is taken when putting the code together, building it on Cygwin is trivial. Yay! I have an ‘installs' folder inside my /home/username folder on Cygwin, and I did the compile in there. Note that if the version number changes the wget line and the working directory name have to be changed accordingly.
$ cd installs $ mkdir gifsicle $ cd gifsicle $ wget http://www.lcdf.org/gifsicle/gifsicle-1.91.tar.gz $ tar xvzf gifsicle-1.91.tar.gz $ cd gifsicle-1.91 $ ./configure $ make $ make install
And that is it! Excellent.
Now, I installed it to take an existing animated gif and loop it.
$ gifsicle.exe -i banner.gif --loopcount=forever > banner2.gif
And that works easily!
For working with animated gifs, gifsicle is really the only tool!
I’m in the mood for using exclamation marks!
This is just something I worked out how to do recently. It’s simple and I think looks quite good.
Let’s say I’m putting together a PowerPoint presentation because I have to. I want to show an example of a document I have put together, a sort of sheaf of pages or screens.
I open GIMP and create a new image that is big enough in pixels to contain everything I want.
File → New
I open them in GIMP as layers into my empty image.
Open → Open as Layers
Then in the new now-not-blank image, Layer → Scale Layer and enter the desired height.
Repeat with the second image, using the same height (in this case).
Position as desired.
(Now, this helps:
Edit → Preferences → Tool Options → Set Layer or Path as active (https://ubuntuforums.org/showthread.php?t=1656588))
Could rotate etc, but not for now.
Layer → Transparency → Add Alpha Channel
Now, there are a few ways to make the background transparent. In this case, I can just go:
Layer → Transparency → Color to Alpha
And I get a screen like this:
If I click on the eyedropper beside the ‘Color’ box (the one currently showing a white rectangle) I can then click on the black of the background to get this:
Note the colour rectangle has turned black and the black background is now denoted as transparent/Alpha by the pattern.
I can then export to png, say, to get a graphic with transparency. But, the Color to Alpha option has a problem. In this case, I have other layers in front of the background. But let’s imagine you had a single layer and wanted to make a red border transparent. If you make all the red transparent, that will include the red component of compound colours, like orange. So any colour that has a red component will be changed. I can illustrate this by flattening this image, so it is a single layer, then repeating the process.
Image → Flatten Image
Then do the same as above — add an Alpha channel and then make black into Alpha. My screenshot now looks like this:
The blacks have been made transparent everywhere, so the darknesses of all the tones have changed — not what I wanted. Instead, I need to use the fuzzy select tool. After adding the Alpha channel, I can do this:
Tools → Selection Tools → Fuzzy Select
Then I click on a visible bit of the background. Then hit Delete. That should select the background and then delete it, leaving only the transparent Alpha channel. Here’s the screenshot — looks OK.
And now I have what I want. In this case, I may as well keep the image with the layers, since that allows more flexible editing at a later date, but this Fuzzy Select business is useful if the image is a single layer, say a bitmap that cannot easily be separated into layers. The fuzzy select is clever, but may not always highlight exactly what is wanted, especially if colours blend into each other. YMMV.
Anyway, once the transparency is as desired, I can Export as a png. I just use the defaults. Now, Here is the resulting png on a very simple page in PowerPoint. I have used PPT options to add shadows to bottom and right; note that PPT is clever enough to only shadow the non-transparent bits of the image. Maybe you take that for granted. I, in my ignorance, was quite pleased.
Transparency lets images overlap more naturally, lets your slide background and theme show through more regularly, and generally gives a more professional appearance since you can get away from that look of simply having a bunch of rectangles.
Well, wanted to print a PDF. I am using Debian 9.5 and printing from Atril to a Brother HL-5340D; pretty standard stuff.
PDF viewed fine, but give these errors on printing (just scanned them in):
Nuts. Tried running pdf2ps and printing the .ps file, but no good. Tried running the .ps through ps2ps and then converting the new .ps to PDF using ps2pdf, but that did not work either.
pdf2sjvu worked, in that it gave a printable file (just ran the converter, opened the .djvu file in Atril and printed it).
Tried running pdftops (note ‘to’ instead of ‘2’) and then printing the resulting .ps file from Atril. That also worked.
The .ps file from pdftops was 13 MB. The .djvu file was 241 KB. Running ps2pdf on the .ps file from pdftops gave a 4.9 MB .pdf, which also printed.
The conversion to DjVu is lossy — there are noticeable differences between the .djvu file and the .ps and .pdf. But not enough to be a problem.
Conclusion: If fidelity is important, error can be avoided using pdftops. If file size is important, pdf2djvu is an option.
pdftops is part of the xpdf package. pdf2ps is part of Ghostscript. pdf2ps is perfectly good in many circumstances, but does not seem to avoid propagating this error, whatever the error is. Possibly there are command line options that would fix the issue.
DjVu is not used all that much, but was designed to reduce file sizes when storing documents digitally. It has many nice features, but is unlikely to ever be a major player.
For a while I had a business website for Brittle gum editing, but I let it lapse (on purpose) when I started at Biotext. Now I just have a page on this blog — here, and pasted in below, since that way I get a blog post out of it as well…
Brittle gum editing was the little company I set up when I freelanced. Brittle gum refers to the trees that are scattered about where I live, not a dental condition.
I made up an icon/logo from a panel on our lead-light front door. I am not a graphic designer…
I now work at Biotext, publishers of the Australian Manual of Scientific Style and writers, editors and designers specialising in technical and government content. As a result, I am not maintaining the Brittle gum website, and this page now serves as a placeholder for Brittle gum’s web presence, which has otherwise ceased.
If you’d like to get in touch with me about Brittle gum editing, please send an email to email@example.com.
Old content — nostalgia…
Using the command line to OCR a PDF file. Done in Cygwin. First, converted pages of the PDF to PPM files, which tesseract can read. Chose 300 dpi.
$ pdftoppm -r 300 pdf-filename.pdf page
The PDF is ‘pdf-filename.pdf’ and the PPM files will have names of the form ‘page-??.ppm’ since the conversion will add ‘-??.ppm’ to the given stem, where ?? is the page number.
Then, run tesseract
$ for f in *.ppm ; do tesseract $f $f ; done
So this loops over all files with ppm as the extension and runs tesseract, and just gives the file name itself as the stem of the output. That means we’ll end up with a bunch of files with names like ‘page-03.ppm.txt’. I could have used basename to chop off the ppm, but there’s just no need.
Next, combine the txt files.
$ cat *.ppm.txt > pdf-filename.txt
This shows another reason for keeping the .ppm in the file name — if I have other .txt files in the subdirectory, they will not get caught up in the cat.
If you are a very thorough person, you might call your final text file something like ‘pdf-filename-tesseractOCR.txt’ or something, to preserve some information about provenance.
This OCR engine is pretty good.
Once the text file has been examined, don’t need the .ppm and ppm.txt files, so
$ rm page-??.ppm*
Of course, if you are surer of what’s in the folder, you might go
$ rm *ppm*
Now, clearly this could all be wrapped up in a very simple script, something like this (script has some improvements over command noted above):
$ cat ~/bin/OCR-pdf.sh #!/bin/bash echo "1. Converting to png (limit 9999 pages or your disk space)" gs -dBATCH -dNOPAUSE -sDEVICE=pnggray -r600 -dUseCropBox -sOutputFile=ZZZZpage-%04d.png "$1" 2> /dev/null > /dev/null echo -n 2. Performing OCR for f in ZZZZpage-????.png ; do echo -n . ; tesseract $f $f 2> /dev/null > /dev/null ; done echo done. prename=`basename "$1" .pdf newname="$prename.txt" echo 3. Creating text file "$newname" cat ZZZZpage-????.png.txt > "$newname" rm ZZZZpage-????.png ZZZZpage-????.png.txt echo 4. Cleaning up
Where I’ve added a few bells and whistles. Note that the error output is all discarded (‘2> /dev/null’ means ‘send output stream 2 (stderr) to /dev/null, which makes it disappear) so if something does not work these bits should be removed.
‘echo -n’ means ‘echo but do not add a linefeed’. I have read that this does not always work, though in a bash implementation it should be fine.
This requires a working GhostScript interpreter. Other conversion paths are possible; the standard tesseract uses Leptonica, which can read ppm and png and other files, so pdftoppm as used above works, though ppm files are big and not compressed, which is why I changed to png — I note that the gs-based version picked up some text that the pdftoppm version did not, possibly because I went up to 600 dpi, but there may be some other factor at work, I can’t say for sure..
If Word is not checking the comments, it is probably because the Comment Text style has got Do not check spelling or grammar selected.
If it is not underlining the misspelt words in the main text, your body style (probably Normal but it could be Body Text or something) probably has that box checked. Or a setting in File → Options → Proofing could be turned off.
Here is how to fix it.
Open the styles pane.
Then select a comment as if editing it. This should cause the Comment Text style in the Styles pane to be highlighted. Right click on Comment Text (or click the little down arrow beside it) and select Modify…
Then select Format (arrow 1) and Language (not shown) and then uncheck Do not check spelling or grammar (arrow 2).
Now the style should not be telling the spell checker to skip over it.
In my experience, this sometimes happens when a document created/modified in Word 2010 is then edited in a later version of Word, though I really don’t know exactly how it happens.
If that does not work, the Comment Text style may be inheriting Do not check from its parent style — usually Normal (you can see in the image above that Normal is in the ‘Style based on:’ field — that’s the parent style that Comment Text is inheriting many properties from). So do the same for Normal and then try again. Doing this for Normal will also make sure that the red wiggly line appears under misspelt words. If you are finding that Word will do the spell check when you click Spelling & Grammar from the Review ribbon, but is not highlighting errors, this could be why.
If that does not work — or you may try this first, I don’t know — go to File → Options → Proofing and go to the bottom. Uncheck Hide spelling errors in this document only (and also, if you want, Hide grammar…) and maybe click Recheck.
Not sure if all steps necessary, but this was what I ended up doing.
I noted this bug once before. Put simply, if Track Changes is turned on in Microsoft Word and you try to do a wild card search and replace, it transposes the replace and mucks it up.
For example, I created a document with the word ‘card’ in it (as in wildcard), and then opened the Search and Replace box and selected Use wildcards and gave it the following instruction:
Replace with: \1OO\2
A word of explanation: Round brackets denote a numbered field. [a-c] means any character in the range a to c. So this command will look for patterns a b or c followed by r followed by d or e. The first matching character will be called group 1 and the third group 2. So the replace command should print the first group, then OO where the r was and then the second group, so that ‘card’ goes to ‘caOOd’.
But it does not. It prints ‘cadOO’ — group 1, then group 2 then OO — it transposes the fields. This is illustrated in the image below.
Now, this is a pain of a bug for an editor who likes to save themselves some work in Word. Why? Because the client should get to see and OK/reject all the changes we make, and for that we use track changes, but this search and replace only works properly with track changes turned off.
So I can either forgo the tracking and edit quickly or edit manually. (Note: I know that in this example I did not need to use wildcards; it is just a demo!)
The really annoying thing is that the screen shot above is from Office 97. That is 21 years ago. This bug is present in the current version of Word, as of November 2018. This bug is 21 years old. This bug is allowed to vote, drink and fornicate. This surely says something about the culture at Microsoft. They sure don’t aim for quality. Maybe not enough people have complained and they’ve got a culture of fixing squeaky wheels instead of aiming for excellence. Probably they spell it ‘eksalense’.
Whatever. It’s pretty underwhelming.
Take home message is that if you can’t get it to work, it is not your fault! Solutions are either (1) forgo the change tracking and turn it off to do this, or (2) write your own Word macro to do it. Neither is very satisfactory.
I’ve long felt that MS has added very little valuable functionality to Word (or Excel) since Office 97 (and the equation editor has gone backwards), but I did not realise just how little progress had been made. Wow.
Note to self
The Word equation editor is pretty badly broken by design. But it is possible to align on equals.
(1) Author equations one by one on consecutive lines with no gaps between.
(2) Select from exactly the first character of the first equation to the last of the last. Not one character extra either side! There must be no ‘non-equation’ objects in the block. If Word is doing ‘smart’ (ie dumb) automatic things with mouse selection, you may find it preferable to use the keyboard to select the block.
(3) Right-click and choose ‘Align at =’ or whatever the form of words might be.