Recursive Folder Copying on Windows

Last week, I had a rather simple task – copy a user-folder from an old laptop to a new laptop – preserve folder structure and keep all metadata (such as file-creation date, last edited etc.).
Right-click copy and paste does not fullfill the needs and usually is rather slow, so I tried to use Windows‘ built-in robocopy.

Doing a quick read over the documentation, I came up with

robocopy C:\SRCDIR D:\DSTDIR /e /dcopy:dat

which I thought would do, what I want – it should copy all files recursively and preserve file attributes and timestamps.

I started the process and expected it to be done after a few minutes – however, the process ran and ran.
The destination directory grew in size, way beyond what it should – according to the size of the source directory.

This prompted me to stop the process and investigate – the source folder was around 5GB, while the destination folder already was over 60GB – what happened?

Weiterlesen

Using spot-color in LaTeX for print-post-processing

I like to use LaTeX to produce nice looking PDF files for printing. So far that has worked pretty well, but in a recent project I ran into issues, so I want to document the solution here. In some printing jobs, there is post-processing involved e.g. when cutting stickers, when putting gold-foil over certain parts of the design or when embossing. In that case, the files need to follow a certain scheme that this areas can be correctly recognized.

In my use-case, the cut-contour lines of a sheet of stickers needed to be given as a separate colour with a certain name. All solutions that I found, where tailored towards proprietary PDF creators like the Adobe Suite or something in this direction. Even harder, if you search for the german words „Volltonfarbe“ in combination with „Latex“ (or even „LaTeX“), you will end up with results offering to buy latex based paint which is not very helpful. „Volltonfarbe“ in this context translates to „spot-color“ and it is very well possible to use spot colors in a LaTeX document.

Weiterlesen

Saving 3D Tiff stacks in Python

Reading and writing image data is a recurring task, and I was wondering, why reading and writing image sequences that are saved in one single *.tiff file are not a standard function in the imaging libraries I regularly use (such as OpenCV, libtiff, Pillow etc.).

Reading 3D tiff files is easy, e.g. with OpenCV

import cv2

res_tuple = cv2.imreadmulti(path_to_file, flags = cv2.IMREAD_UNCHANGED)

will do the job. However, when trying to save the resulting array back to a file, it will fail. A working filesave for 3D tiff stacks could e.g. look like this:

from skimage.external import tifffile as tif
import numpy as np

image = np.ones((100,10,10), dtype=np.uint16)
tif.imsave('test.tif', image)

Of course the tifffile library will do that as well, however, I find it more convenient to have only scikit-image installed and let it call the tifffile as external library.

Getting Started with Python + Anaconda + Spyder

In the last few years I have done quite some programming work with Python and started to love both the Anaconda distribution (I might do another blog-post on that topic) and the Spyder IDE. If you are very new to Python and programming, this might be a little overkill, but it will be a very clean basis to start with and no drama, once there is the need to update or upgrade. So follow these steps if you want to get a first quick-start into Python with using the Spyder IDE and Anaconda.

Weiterlesen

How to get external DLLs into a python package

So, I recently stumbled upon the problem of having to include an external DLL into a python package, which should also work when turned into a windows executable by pyinstaller. This post, is meant to be a help if you run into the same problems I was having (and of course as my personal prosthetic knowledge).

The structure of this post will be:

Weiterlesen