Always Use Google.com in Chrome

I read English, mainly. I also read Hebrew, but not enough to want to do web searches in Hebrew by default. I live in Israel, so every time I use the omni search in Chrome I’m redirected to google.co.il, and of course, most searching results are Hebrew pages. This also applies to my Android tablet which is doubly annoying seeing how the omni search settings in Chrome are the same ones used by Google Now and the default search box across the OS.

Here is an easy trick to not get redirected to your local Google page.

1. Open Chrome and type “google.com/ncr”
2. Search for something in the Google page (not the omni search)
3. Close Chrome completely (different in each OS)
4. Open Chrome again, but this time search for something in the omni box
5. You should be greeted by a yellow bar asking if you want to switch to your local Google or keep using Google.com

Enjoy being able to always use Google.com in Chrome :)

Convert Images in Terminal on a Mac

There is some wanky muss with my Piwigo install so I’ve been playing around with all sorts of things. One thing I found is that it no longer seems to like “.png” files as “pwg_representative” for video files. Okay fine, but seriously why all of a sudden? But I digress.. The built-in “sips” (Scriptable Image Processing System) command on a Mac is an easy way to convert a bunch of images from png to jpg. This also works with other formats by the way.

sips -s format jpeg My_Picture.png –out My_Picture.jpg

An oddity for sure is that after “format” you need “jpeg” not “jpg” and yet if you specify “My_Picture.jpeg” it will warn you that it changed your file name to “My_Picture.jpg”. Way to go Apple. Anyway its a useful command, as the name suggests, its good for scripting. Here is how I scripted it..

for PICTURE in `ls pwg_representative | grep png`; do sips -s format jpeg pwg_representative/$PICTURE –out pwg_jpg/`echo $PICTURE | sed ‘s/.png/.jpg/’`; done

Feel free to suggest a more elegant way to do it.

 

Compress and Rotate Videos

For easier and faster viewing of videos online, I compress them before uploading to my server. My goto application for this is HandBrake. It’s cross-platform, has lots of options as well as easy presets, does a really good job of compressing, and is open source.

The two options HandBrake is seemingly missing that I’ve been wanting.. batch and rotate. It does have a queue that can be processed, but all things added to the queue are done so manually. And no rotate. However.. HandBrakeCLI DOES have these options. Because of course its CLI you can script to to do batch, and they’ve added a rotate feature.

The rotate is a little funky and not documented so well though. From various forums it seems that the options are:

  • 1 = flip X axis
  • 2 = flip Y axis
  • 3 = flip on X & Y axes (180 degree rotate)
  • 4 = flip? (anyway this does a 90 degree rotate)

So the command I used was:

HandBrakeCLI -i vid_file.mov -o vid_file.mp4 –preset=”Android”, –rotate=4

Then I scripted the process for the entire directory.

for FILE in `ls`; do HandBrakeCLI -i $FILE -o ../export/`echo $FILE | cut -d”.” -f1`.mp4 –preset=”Android”, –rotate=4; done

Cool. I’ll be bypassing the GUI and using the CLI from now on. 

Generate Video Thumbnails using Terminal on a Mac

I use a hosted service that does not support video services like ffmpeg. That means that if I use a software package like Piwigo that supports automatic video thumbnailing, I can’t take advantage of that feature. I can however upload my own thumbnail of a video, and if its the same file name (ex: vacation.mp4 and vacation.png) then it will automatically apply that image to my video. I wasn’t able to find a thumbnail generator that worked well and was free. Enter Terminal and the built in services to a Mac.

qlmanage -t -s 512 your_video.mp4 -o .

This command will use the QuickLook Manager utility to generate a 512 sized thumbnail and output it to the current directory. I wrote a quick one-liner to generate for all the videos in my directory that I wanted to upload.

for i in `ls`; do qlmanage -t -s512 $i -o .; done

Then another one-liner to remove the double file extension.

for i in `ls | grep png`; do mv $i `echo $i | cut -d”.” -f1,3`; done

As with all of my scripts, its not the most elegant way to do it, but it works.

Change EXIF Data with ExifTool on a Mac

Ever want to change the EXIF data in your pictures? I’ve had this question responded to in the form of another very shortsighted question “Why would you want to do that?” Here are a few reasons why you might want to update your EXIF data.

  1. Your camera clock went wanky and your pictures came out with the default year of the camera (apparently the vacation we just had actually happened in 2006, at least according to iPhoto).
  2. You took pictures in another timezone, but your camera clock is still at home.
  3. You want to resize your photos but retain the EXIF data.

Right, so here is how to do it.

First, grab a brilliant little tool by Phil Harvey called ExifTool. Seriously, thanks a lot Phil, ExifTool really is brilliant. There is a metric butt-load of options for ExifTool, but if you need to just change the date/time the command goes something like this.

exiftool -AllDates=’2014:01:31 15:35:33′ -overwrite_original your_picture_file.jpg

So that’s nice, but how about 2-300 pictures? Here is the one-liner I used to change my sister’s camera photos that were set to the correct time and day but in 2006. There are for sure more elegant ways to write this. This was quick and what came to me so it fit the bill.

for PIC in `ls Camera/`; do DATE=2014:`exiftool ./Camera/$PIC | grep Create | cut -d’:’ -f3-6`; exiftool -AllDates=”$DATE” -overwrite_original ./Camera/$PIC; done

This changed the year in all the date stamps to 2013 while retaining month, day, and time information. Feel free to make it more extensible and elegant as you see fit.