This is a list of tips for converting and working with and printing documents and photos.
 
 
I'm out of black ink but still have color.  I need something printed now and don't have time to buy another ink cartridge.  
 
This trick converts the black (rgb 0x000000) colors in a graphic to blue (rgb 0x0000FF), so I can print with the color cartridge:
 convert original.png -fuzz 25% -fill "rgb(0,0,255)" -opaque "rgb(0,0,0)" new.png
 
 
I need to edit a PDF file and send it to someone, but I don't want to print it out, make the changes to the printed copy and scan it back in.  I'd like a paperless way to make my changes.
 
If the document is in PDF format, use Inkscape (or InkscapePortable).  Open the PDF file.  Be sure to select Poppler/Cairo import under Import Settings.  Then, you can export it as a graphic file a page at a time.
You can edit a page in Inkscape itself or output it as a graphic file and edit it in another graphics editor.  Export each page you need as a separate graphic using Inkscape.  When you're ready to combine them and create a new PDF with the contents and your changes, use wkhtmltopdf.  
 
Create a simple html file similar to this:
<html>
<body>
<img style="height: 11in" src="graphic000.jpg">
<div style="page-break-after: always;"><span style="display: none;">&nbsp;</span></div>
<img style="height: 11in" src="graphic001.jpg">
</body>
</html>
 
Add an img tag for each graphic of a page that you want to output and make sure the name of the corresponding graphic file is given.  Separate each graphic with a page break command as shown in the example.  
 
Then convert the document to PDF from HTML:
wkhtmltopdf --enable-local-file-access document.html document.pdf
 
 
I need to upload a graphics file and send it to someone, but the application I'm uploading to is complaining that the graphic is too big.
 
You can use ImageMagick to resize an image in a variety of ways.
 
You can decrease the size of the image:
convert original.png -resize 50% new.png
 
You can resize the image to specific dimensions:
convert original.png -resize 64x64 new.png
 
How do I find out the size of an image so I can resize to a specific bit length and bit width?
 
Use ImageMagick's identify program:
identify original.png
 
GraphicsMagick is a fork of ImageMagick.  The same tips work with GraphicsMagick.  The only difference is the syntax.  You need to run the gm program instead of separate programs like convert and identify.  So add gm in front of any ImageMagick commands.  For instance:
gm identify original.png
 
I just got used to VirtualBox and ended up having to switch to QEMU. VirtualBox seems to run better than QEMU. I tried to load several operating systems in QEMU that ran fine under VirtualBox and they failed. Decided to try a Debian netinst because that works well with most machines. Then I had to figure out all over again how to get files between the host and guest systems. It's harder to find documentation on what you're looking for with QEMU as compared to VirtualBox.

The first step is to download and install qemu someplace. I'm assuming it's in the path. Otherwise, you need to specify where to run it from.

Next step, create a virtual disk to install the operating system to. The following creates a 2 GB image file in raw format. You can choose other formats.

qemu-img create linuximage.img 2G

I'm using an ISO for 64 bit Linux, so I use qemu-system-x86_64. For 32 bit systems, I can use qemu-system-i386. There are options like qemu-system-i386w.exe which I was wondering about. Turns out these are for use on Windows systems. They prevent bringing up a console when as well as a window when running. However, I typically run everything from the command line, so there's no advantage to this. Windows programs running in console don't create a new console. I recommend sticking with the standard versions without the w especially if you're running from the command line or on a non-Windows system.

I downloaded a Debian netinst ISO and put it in the iso directory. This is the command I used to start QEMU so I could install Debian to the linuximage.img file.

qemu-system-x86_64 -hda linuximage.img -cdrom iso\debian-10.10.0-i386-netinst.iso -device ac97 -net nic,model=ne2k_pci -net user -rtc base=localtime -m 1G -boot order=dc -usbdevice tablet

The -m option specifies RAM and I gave it 1 Gigabyte. Once you run the command, hopefully the operating system should boot from the ISO as if it was a CD. You can then proceed to install it to linuximage.img which should appear as the first hard drive on your system. Once the system is installed, you probably want to Power Down and/or Quit QEMU.

Use the following command to boot from the image rather than running from the ISO file.

qemu-system-x86_64 -hda linuximage.img -device ac97 -net nic,model=ne2k_pci -net user -rtc base=localtime -m 1G  -boot order=c -usbdevice tablet

The -usbdevice tablet setting seems to help smooth out mouse support which didn't work well without it.

Now comes the hard part, I wanted to move files back and forth from the new system. If the files are fat32 (such as a ReactOS image, you can mount the image and read the files. That doesn't help much with operating systems that use other disk formats. You can load images as floppies or cdroms (typically read only) or add another hard drive. So, the idea was to add a second drive that was formatted using a format the host system could read. I created another image and attempted to format it in using the Guest operating system in a way that the host could read. That failed. I recommend mounting the image and letting the host operating system format it. Then, the guest operating system can be set to access it as a second drive.

To do this on Window, I used a program called ImDisk.
https://sourceforge.net/projects/imdisk-toolkit/
Latest versions of Windows are supposed to allow you to mount an image as well.

I created a new image using:
qemu-img create drive.img 2G

Once I mounted the image using ImDisk, the operating system asked if I wanted to format the image and I let it do the formatting. Then, I could access the image using QEMU. Make sure the drive is not mounted on the host system before using it with the guest system and vice versa.

qemu-system-x86_64 -hda linuximage.img -hdb drive.img -device ac97 -net nic,model=ne2k_pci -net user -rtc base=localtime -m 1G  -boot order=c -usbdevice tablet

When I tried formatting the drive using Linux in QEMU, it wanted to access the new drive as /dev/sdb1. When I just use the image created from Windows, it used /dev/sdb.

Once you've created and formatted the extra image, you can access it in your virtual operating system. If you're running Linux virtually, you'll need steps like these.

mkdir -p /mnt/data
mount -o defaults /dev/sdb /mnt/data

They needed to be performed as root or you need to get sudo working properly first. Directory creation only has to be performed once. The mount needs to be done each time you activate the operating system and want to access the image unless you add the information to auto mount it in /etc/fstab. You can also unmount the drive using umount.

Once the drive is mounted, you can move files to and from it. You can see if there's anything on the image using:
ls -l /mnt/data
Copy or move files from /mnt/data or whatever location you mount the drive at as well.

While I couldn't access an image I formatted in the guest system, I did want to go through the steps. It worked fine from within the host and was readable from there.

Install fdisk. Since I'm using fat32, I also needed to install dosfstools. I found the tools in /usr/sbin and had to run from that directory since it wasn't in my path. The commands below assume programs are in the path. They probably need to be run as root or using sudo.

fdisk -l

This shows your images so you can find their names. I set drive.img as -hdb so it shows up as /dev/sdb on a Linux system.

fdisk /dev/sdb

The fdisk program will prompt for further information.

At the fdisk command prompt, I gave it the o option. This creates a new DOS partition. The next command was n to set a partition type. I chose p for primary. I chose the default partition number 1. It brought up first and last sector options and I chose the defaults for both. At the command prompt, I chose t for partition type and gave it a hex code of b which selected W95 FAT32. At the command prompt, I selected w which wrote the changes and exited the program. From the normal command prompt, I ran the following:
mkfs.vfat -F 32 -n WINSTORAGE /dev/sdb1

This should format the image and name the image WINSTORAGE. Windows prefers upper case for disk labels.

Once done I was able to use mkdir to create a directory under /mnt to mount it. In this case it needs to be mounted as /sdb1 not not sdb. The result made an image that worked fine in the guest system but wasn't recognized on the host.

If your host system is a Linux system, it might be helpful to use a more familiar format like ext2 or ext3 instead of fat32. On the other hand, many flash drives use fat32 and most systems can read them, so it might be a useful solution as well. If you create the second image before installing the new operating system, depending on the installation process, it might recognize the extra image and incorporate it automatically. Just make sure not to reformat it when installing the operating system.

The mtools programs can be used on various operating systems and can be used with emulators and images formatted for DOS. Wondering if it could be used to format a mounted image file as fat32 on systems that don't support it natively.

I was also able to successfully create an ISO image on the host system using mkisofs and load that as a virtual CDROM on the guest.

mkisofs is available on Windows with various software. I typically installed DVDStyler and used the program it supplies. Debian and some systems typically don't supply cdrtools which contains mkisofs. Many systems use another package which emulates or gives equivalents to commands cdrtools supplies. GRML is a Debian based distribution that does offer the original cdrtools package. There are some arguments over copyright which kept cdrtools from being added to some distributions. I also found a utility that worked only on Windows that could create ISO files. It was used by some ReactOS developers. Nice thing was that it built easily from source using MinGW.

Assuming my files are in the tmp directory below the directory I'm in, I can run mkisofs with the following command to make an ISO file.
mkisofs -r -R -J -l  -o test.iso tmp

I can add the image using a command like this one.
qemu-system-x86_64 -hda linuximage.img -drive id=cdrom0,file=file,index=1,media=cdrom,file=test.iso -device ac97 -net nic,model=ne2k_pci -net user -rtc base=localtime -m 1G  -boot order=c -usbdevice tablet

Once in Linux, the cdrom can be accessed after mounting it with:
mount /media/cdrom

I've used that technique to get Debian to install successfully with QEMU. Haven't had much luck with other systems yet including other versions of Linux. I'd also like to get Androic-x86 or Bliss OS working at some point. XFDOS would be another interesting option to try.

I did finally get ReactOS running in QEMU. Reactos is tricky to load. The Reactos version used must be 0.4.14-RC or higher.

I created an image using the native QEMU format as recommended on the ReactOS site.

qemu-img create -f qcow2 reactOS.qcow2 2G

I installed ReactOS on the image by following the prompts after using this command:

qemu-system-i386 -drive if=ide,index=0,media=disk,file=reactos.qcow2 -drive if=ide,index=2,media=cdrom,file=iso\reactos-bootcd-0.4.15-dev-2847-g0ffbbab-x86-gcc-lin-dbg.iso -m 1G -device ac97 -net nic,model=ne2k_pci -net user -rtc base=localtime -usbdevice tablet -boot order=dc -serial file:reactos.log

Most of the options I picked were defaults.

After the image is formatted and the operating system is installed, power down and/or quit QEMU.

I ran the following command to complete setup after the ISO was no longer accessible from the CDROM drive. It let me set up the system.

qemu-system-i386 -drive if=ide,index=0,media=disk,file=reactos.qcow2 -drive if=ide,index=1,media=disk,file=drive.img -m 1G -device ac97 -net nic,model=ne2k_pci -net user -rtc base=localtime -usbdevice tablet -boot order=dc -serial file:reactos.log

After it's set up as desired, power down and/or quit qemu.

Now, I can run the following command to move files to and from ReactOS within QEMU using the drive.img.

qemu-system-i386 -drive if=ide,index=0,media=disk,file=reactos.qcow2 -drive if=ide,index=1,media=disk,file=drive.img -m 1G -device ac97 -net nic,model=ne2k_pci -net user -rtc base=localtime -usbdevice tablet -serial file:reactos.log

It's accessible as e:. The d: drive is still reserved for the CDROM device.

At one point when I restarted the image, it asked me to press Ctrl-Alt-Delete to get into the system. I found out you can send special keys to QEMU by pressing alt-ctrl-2 to get to a screen where you can enter commands. You can emulate keys using sendkey. I entered sendkey alt-ctrl-delete. Return to the original screen using alt-ctrl-1. This actually accomplished nothing in this case, because the screen was coming due to an error with the system, possibly the registry. I ended up having to reinstall ReactOS to fix it. Sending alt-tab this way once the system was reinstalled worked well.

ReactOS is interesting and can run some great Windows programs. However, it does crash more often than I would like. Can't help thinking a Linux system with Wine would be more stable. There are several themes, but I miss the Windows XP Silver Metallic theme. Supposedly, you can copy the .msstyle file over from a Windows XP machine to ReactOS and it should emulate the style.

Still investigating what other operating systems will run under QEMU and what commands they require.

So, that's my cheat sheet of useful QEMU commands to date. It does seem to have some advantages to VirtualBox, but so far, I haven't been able to run as many operating systems on it. You also have to decipher what to use in the command line or it may fail to run. Once you have the techniques down and the images created, it seems to work well. It seems less complicated to get files in and out than using VirtualBox Guest Additions. Unfortunately, documentation for how to accomplish it is difficult to find.
I'll be interested to see if QEMU will allow access to an extra image when running an Android operating system. VirtualBox Guest Additions typically wasn't an option for most virtual Android based operating systems. Hopefully, that's all that's needed to get a virtual operating system up in QEMU and develop/build applications natively within the guest system.
I really like FOSSIL for version control:
https://www.fossil-scm.org/home/doc/trunk/www/index.wiki
You can easily build it from source and it's cross-platform portable. It was written by the developer of sqlite. That being said, most projects will be using git. So for ease of look-up, I'm creating a cheat sheet of the git commands I use most frequently.

Git is much harder to build from source. You can use it cross-platform though. Most Linux distributions have a git package and there's Git for Windows formerly Portable Git for use on Windows systems.
Some git libraries with source to build them include:
https://github.com/libgit2/libgit2
https://github.com/oridb/git9


You can view git code via the web using various methods. Gitweb is one such method. If you're using Windows and just using the code locally or on a secure local network with shared drives, you can use portable xampp. It comes with gitweb and and an Apache web server. You just need to configure both of them. You can use it to easily view a repository on a shared remote drive or a local drive via a web browser. If you're on a Linux or BSD system, use your package manager to download a web server and gitweb. Setting up a web interface using xampp and a shared drive was relatively easy. Setting up a web interface like gitweb with your own web server and accessing via URL is not so easy. I asked several Linux users groups and forums for recommendations. The typical answer was to use a third party product like github and let someone else do the work. Not very helpful if you want to know how to do things for yourself. Since I needed an intranet solution that was secure, I went with the method of setting up a shared drive and using portable xampp with gitweb. I use portable versions whenever possible because it isolates the files used. In this case, I'm referring to portable in terms of moving files to other locations or running completely from a flash drive. There's also portable as in cross-platform portable in terms of being able to build code from source on a variety of operating systems and with difference compilers. Portable apps (programs that are portable across file locations) make it easier to move or copy everything to another machine and to update versions. I've had to do that more than once.


I've been trying to update a project on Github for a few years now and it keeps failing. That's after receiving advice from several people in some of our local developer groups. They couldn't figure out why it was failing either. I finally tried Codeberg and it worked on the first try. Unfortunately, the original version of the project which I cloned is still on Github and I'm not sure how I'm going to get my changes over to it. At least I can get my changes into the Codeberg repository now.


Some basic commands for use with git:

master is the name of the version control branch. origin typically points to the remote source repository that the code is stored in. The default is to use origin but you can add another name for your project and use it instead. The source repository can be a remote URL or a shared drive. The location typically ends with .git

I typically assume the latest version is on my machine and I'm pushing it to the repository. If others are editing the same code or the latest version is in the repository, you'll need to do a pull before you do a push. If you get out of sync because you've forgotten to do the pull, but you know you have the latest and you just need to fix things, you can do a reset.

Substitute the name of the project for the word project in the commands below.
To add another source repository:
git remote add project //remotedrive/git/git.git
Once it's added, you can do a git push for that project.
If you don't want to add the source repository each time before working with git, you can add it to the configuration. There should be a config file under the hidden directory /git/git/.git. Edit the config file and add the repository there. For example:

[remote "project"]
url = //remotedrive/git/git.git
fetch = +refs/heads/*:refs/remotes/project/*


To push code from your machine:

You can use *.* to push all code or you can use other wildcards or a specific file name. The m parameter is for adding a message and you can use any text you want. If you're using gitweb to display the repository, the message information for each commit will appear under summary. You can then drill down to see information about the state of the code at the time of that commit.

Use cd to get to the directory where the source code to be saved with version control is located. If you're on Windows, do this in git-bash. Example:
cd /c/git/git

git add *.*
git commit -m 'data_YYYY_MM_DD'

git push project master

You can check the status during any time during the add and commit using:
git status


To get code to your machine using a pull:

First, cd to the location where you store the code locally. For example, on Windows using a command prompt:
cd /git

git pull project master


If you've tried to update a project and it's out of sync with other systems that also have the project, use:
git reset --hard project/master


To clone a project:

If you didn't create the project on your machine originally and you want to retrieve it from the source repository and work with it on your on machine for the first time, you can clone the source repository.

To clone a git repository, cd to the location where you want to put it. For example, on Windows using a command prompt:
cd /git

Clone the location of the source repository. It could be a shared drive or URL. The location typically ends with .git
git clone //remotedrive/git/git.git


To push code from a cloned repository on my local machine to an online repository:

I cloned the code to my local machine.

To change the branch from master to main:
git branch -m master main

I set the remote repository:
git remote add [repository] [url]
Fill in a name for the repository and the url you're pushing it to.

I had to force the changes to the repository since there was already a README.md file and a license and I wanted to override with the original project's information:
git push -f repository
Note that the files already there (README.md and LICENSE) were lost.
However, this moved the original project with it's history to a new online repository.

October 2025

S M T W T F S
   1234
567891011
121314151617 18
19202122232425
262728293031 

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Nov. 1st, 2025 04:59 am
Powered by Dreamwidth Studios