Saturday, February 28, 2015

One-liner command for changing image resolution

The command in this post requires the GraphicsMagick package (see this for an explanation). GraphicsMagick commands start with gm in front of them.

Use the following command in Terminal, and GraphicsMagick will change your image resolution.
gm convert original.jpg -resize 120x120 output.jpg
The image will be scaled so its largest dimension is 120 pixels.

See this for an explanation of what other options are available for this command.

Tuesday, September 30, 2014

Get a list of files changed between two revisions of SVN

If you want to see which specific files where changed between two revisions of SVN, then this is a handy and quick reminder, taken from here:
svn diff --summarize -r {newRevision}:{oldRevision}
You can change the order of {newRevision} and {oldRevision}.

For instance, to get the list of modified files between revisions 60 and 50 we write
svn diff --summarize -r 60:50
This will output a list like this:
 M       path/to/modifiedfile
 A       path/to/newfile
 D       path/to/deletedfile
 .
 .
 .


Bonus:
If you want to see the detailed diff between the versions of modified files, you may remove the --summarize suffix. But the output will be very bland and hard to read. See this post to learn how you can make that output look better.

Wednesday, August 6, 2014

How to delete (and reset) FileZilla preferences in OS X

In order to start with a clean copy of FileZilla (so that, for instance, it allows you to save site passwords again, after once choosing not to!) follow these steps on Mac OS X:

First stop (close) FileZilla. Then navigate to the home directory by typing cd ~. Then locate .filezilla by typing ls -a (optional, obviously!). Remove it by using:
rm -rf ~/.filezilla
Now open FileZilla again!

Wednesday, May 21, 2014

One-liner command for creating animated GIF

The command in this post requires the GraphicsMagick package (see this for an explanation). GraphicsMagick commands start with gm in front of them.

  • First have the individual frames of your animation ready, and give them similar ordered names, say frame01.png , frame02.png , frame03.png , etc. The numbers determine the order in which the frames will appear in the final animation.

  • Put all the frames in a folder (say, animFrames/ ).

  • Now use the following command in Terminal, and GraphicsMagick will convert your frames into an animation anim.gif .
    gm convert -delay 5 animFrames/frame*.png anim.gif
    
    The option -delay determines the delay between displaying frames (the unit is 1/100th of a second).

    See this for an explanation of what other options are available for this command.

Command-line graphics editors: GraphicsMagick and ImageMagick

GraphicsMagick and ImageMagick are both powerful command-line programs for manipulating various image types. They have similar syntax, except that GraphicsMagick commands start with gm while in ImageMagick different commands have different binaries, so you just type the command name directly. For instance, the command for converting file types to each other in GraphicsMagick is
gm convert originalFile targetFile
while in ImageMagick it would be
convert originalFile targetFile
I have found GraphicsMagick to be the faster of the two packages.

Thursday, March 6, 2014

One-liner command for changing pdf size

The commands in this post require the GraphicsMagick package (see this for an explanation). GraphicsMagick commands start with gm in front of them.

One use of these programs is to resize pdf files. I found a solution here, which was really helpful. I will repeat and expand on it.

 TLDR Version

Use the following command in terminal:
gm convert -density 300x300 -quality 25  -compress jpeg  originalFile.pdf targetFile.pdf

 Explanation

Now let's see what that command does. First the bare bones:
gm convert  -compress jpeg  originalFile.pdf targetFile.pdf
This command will compress your pdf file for you, but will use default values for the output's density and compression quality. Unfortunately, the resulting output is overly compressed and unusable for most uses.

-compress jpeg defines the type of image compression. Read more about it here.

Adding the -density 300x300 makes sure that the pdf's resolution is satisfactory. Read more about it here.

If the output file's size is till too big, you can either lower the above resolution, or increase the compression level of the pdf (and lower its quality). That is what the -quality 25 command does. The default value is at the higher quality of 75. The number can be anything from 0 (lowest quality) to 100 (highest quality).
Read more about -quality here.

Thursday, February 27, 2014

Symbolic links in Unix-like OSs

In Unix-like systems, if you have a command-line app, and you want to run it, you will have to type its full address in the terminal, like this
/Users/name/myFolder/app
Or you can navigate to its folder with cd /Users/name/myFolder and then use ./app to run it.

Another way would be to move that application to a folder that is in the system's $PATH . But if you don't want to move the application (and assuming you don't want to change your $PATH either), then you can add a shortcut for your application to a folder that is included in $PATH . To see the list of these folders, type
echo $PATH
and then pick one of the folders displayed. For example, /usr/local/bin . Now we will add a symbolic link (like a shortcut) to our application in this folder. This can be done by
ln -s /Users/name/myFolder/app /usr/local/bin

Perfect! now you can run your app by simply typing app in any terminal! (Of course, app should be the specific name of your app.)