Posts Tagged ‘resize’

resize an .mkv file

December 5, 2015 Leave a comment

I wanted to play a 720p .mkv file on an old laptop but it was painfully slow. How to reduce the quality of an .mkv file?

I found the solution here. The following worked for me:

$ ffmpeg -i Movie.mkv -vf scale=-1:360 -c:v libx264 -crf 18 -preset veryslow -c:a copy MyMovie_360p.mkv

Visit the link above for an explanation of the parameters.

Categories: bash Tags: , , , ,

resize an image to a given width by keeping the aspect ratio

You want to resize an image to a given width but you want to keep the width/height ratio of the image.


convert -resize 200 big.jpg small.jpg

Here the new width will be 200 pixels.

Categories: bash Tags: , ,

[manjaro] /tmp is too small, cannot install new software

March 10, 2015 Leave a comment

I have a Manjaro virtual box and I ran into the problem that tmpfs is too small, thus /tmp has not enough space to install a new software.

I could increase the size of tmpfs with the following command:

$ sudo mount -o remount,size=2G,noatime /tmp

The previous size was 512 MB, now it’s 2 GB. After this I could install JDK 8 :)

Note that these settings are reset when you reboot the machine.

Categories: manjaro Tags: ,

Resize .tif file and convert to .jpg

November 7, 2011 Leave a comment

Use case
In the lab we have a photocopier that can scan too. Quite cool, you can precise your email address and it sends you the scanned page in .tif format.

However, pages must be scanned one by one and each of them is sent as a separate .tif file. Each .tif file is around 2.8 MB large with a resolution of 4900 x 7000 pixels. How to resize them and convert them to .jpg files? Gimp is one way but could we solve it in command-line?

Put the .tif files in a folder and create a subfolder called “out”. This way the output won’t be mixed with the input.

for i in *.tif; do echo $i; convert $i -resize 24% out/`basename $i .tif`.jpg; done

Each .tif is made smaller (width around 1200 pixels) and converted to .jpg.

As a final touch, convert the JPGs to a PDF file.

cd out
convert *.jpg doc.pdf

Does anyone know how to to resize an image the following way: let width be 1200 pixels and keep the aspect ratio? Above the 24% was the result of a manual computation…

Answer: just use “convert -resize 1200 in.tif out.jpg“. The output will have width=1200 pixels with the same ratio as the input image. (Thanks Yves for the tip.)

Create a new partition from an NTFS partition

February 13, 2011 Leave a comment


On my laptops, I ran out of space under Ubuntu; the root partitions got full. The two cases were a bit different:

  1. On the first machine, I had a large NTFS partition where I stored multimedia stuff (movies, MP3s).
  2. On the second machine I had an NTFS partition with Windows 7 on it.

Before you read on, I want to warn you that resizing partitions may lead to complete data loss. It’s always a good idea to make some backups before doing anything risky. I take no responsibility if something goes wrong!

Goal: I wanted to cut off a piece from the end of the NTFS partition and create a new ext3 (or ext4) partition. For this, we need to resize the NTFS partition.

Let’s see the two cases:

  1. Resizing an NTFS partition with no Windows on it. Use Defraggler to defrag the partition. If everything goes well, the end of the partition will be empty. If this is not the case, run Defraggler once again. You can also run Windows’ own defrag utility. If the end of the partition is free, you can use gparted to resize the partition.
  2. Resizing an NTFS partition with Windows on it. Follow the instructions of the first step concerning the defragmentation. However, it can happen that you will have lots of free space at the end, but at the very end you’ll have some unmovable blocks, e.g. page file. Windows’ Disk Management can also shrink a partition, but in my case it didn’t work, I guess because of these unmovable elements. So I took the risk and resized the partition under Ubuntu with gparted. After reboot, everything was OK.

After resizing, when you reboot Windows for the first time, be prepared that it will check your disks. It’s normal, Windows noticed that the NTFS partition changed, it’s just doing its job.

Categories: ubuntu, windows Tags: , , ,

Open Disk Management in Windows 7

February 13, 2011 Leave a comment


You want to use Windows 7’s Disk Management utility to edit your partitions but you don’t find it. Where the hell is it?


Click on Start and in the search field type in the following: diskmgmt.msc, then press Enter. Disk Management will start.

Or, open a DOS shell and launch diskmgmt.msc.


Create a folder on your desktop called System, and place a shortcut on diskmgmt.msc in it. This way Disk Management will be easily accessible.