Archive

Posts Tagged ‘images’

I am KB3RXM

November 18th, 2008

I got my callsign today:

KB3RXM

KB3RXM

Now, to actually buy a radio. I’ve been doing a lot of thinking, and I think I might be happiest with a home base station after all, even though I live in an apartment. I may buy a little portable station kit to build, but that will be secondary to the large fixed station. Now, I just need to figure out exactly what I want. Power is a pretty big deal since I think I’ll be in a pretty suboptimal antenna situation. I am going to probably purchase a HamStick antenna for the balcony as I’ve seen some evidence that it may perform pretty well out there, and it’s pretty stealthy.

I’ll probably be testing for my General license on December 6th in Reisterstown. That should be fun…


Uncategorized , , , , ,

Putting Images on the iPod Touch from Linux

August 6th, 2008

Idea

I wanted to put images on my iPod Touch without using iTunes since, as most of us know, there is no good way to use it from Linux. It turns out there is a magic directory on the iPod Touch where it saves images from Safari. I simply looked at how it saved them, and applied it on my box here at home.

Requirements

  • Jailbroken iPod Touch (I used WinPWN), with OpenSSH installed and working (the root password is alpine)
  • Firmware 2.0 (Though, 1.x may work, I just haven’t tried it)
  • A Linux box with a bash shell
  • Cool images
  • convert and mogrify from ImageMagick installed

Method

These instructions might work for the iPhone as well. YMMV

All of your images must be in the format IMG_XXXX.YYY where XXXX is a number < 9999, and YYY is either JPG or THM (THM is a thumbnail). To rename our files, I use a simple trick I outlined in my last post:


EII=4; for i in *.jpg; do ls $i; \
NEWNAME=IMG_00`printf "%02d" $EII`.JPG; \
echo Renaming $i to $NEWNAME; \
mv $i $NEWNAME; EII=`expr $EII + 1`; done

That will rename all the JPEG files in order from 4 to, in my case, 62. Now, I have to make the thumbnails:


for i in `ls *.JPG | cut -d '.' -f 1`; do \
convert $i.JPG -resize 75x75! $i.THM; \
done

The 75×75! part makes sure they are exactly those dimensions. You end up with something like the following:


IMG_0004.JPG  IMG_0016.JPG  IMG_0028.JPG  IMG_0040.JPG  IMG_0052.JPG
IMG_0004.THM  IMG_0016.THM  IMG_0028.THM  IMG_0040.THM  IMG_0052.THM
IMG_0005.JPG  IMG_0017.JPG  IMG_0029.JPG  IMG_0041.JPG  IMG_0053.JPG
....

Now, note that the iPod can only display images under 100KB (to my knowledge). If your high-res image is too large, it will just display the magnified 75×75, which is really ugly. So, make sure all your images fit that description, and if they don’t, mogrify -resize them until they do (or take other measures as necessary). I used this:


mogrify -resize 400x *.JPG

All my images turned out to be between 30 and 90 KB. This also keeps the aspect ratio, unlike the 75×75!.

Now, SSH into your iPod (if you can’t do this yet, google it). You should have the following file:


/var/mobile/Media/DCIM/.MISC/Info.plist

Open this file in vi, and observe the plist>dict>integer part of the hierarchy:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>LastFileGroupNumber-100</key>
        <integer>62</integer>
</dict>
</plist>

So, I put 62 in there since the last image I have is numbered 0062. It’s a very simple idea. Now, just load them onto the iPod:


scp IMG_00* root@ipod:/var/mobile/Media/DCIM/100APPLE/

Let’s have a look from the iPod console!


HanksTouch:/var/mobile/Media/DCIM/100APPLE root# ls
IMG_0002.JPG  IMG_0014.THM  IMG_0027.JPG  IMG_0039.THM  IMG_0052.JPG
IMG_0002.THM  IMG_0015.JPG  IMG_0027.THM  IMG_0040.JPG  IMG_0052.THM

Beautiful. Now, to test it…


Uncategorized , , , , , , ,

Photoslice in Bluecloth and Mephisto

January 5th, 2008

So, I found this today, and it is awesome. I wanted it in Bluecloth so I could use it in Mephisto. Here’s how.

First, I needed to make it so I could still do normal images, but turn on coolness if I want. Here’s the goal I came up with for the grammar:


[![](thumburl.jpg)](imageurl.jpg "Scrolly Text at top" "photoslice")

Here’s the first test, with a single image:

And now a set with a namespace:



I did it by simply modifying the regex and image url parsing function in BlueCloth like so:

  InlineLinkRegex = %r{
    \(            # Literal paren
      [ ]*        # Zero or more spaces
      <?(.+?)>?     # URI = $1
      [ ]*        # Zero or more spaces

      (?:         # title
        ([\"\'])    # Opening quote char = $2
        (.*?)     # Title = $3
        \2        # Matching quote char
      )?          # Title is optional
      [ ]*        # Zero or more spaces
      (?:         # rel
        ([\"\'])    # Opening quote char = $2
        (.*?)     # rel = $5
        \4        # Matching quote char
      )?          # rel is optional
    \)
    }x

    # and later...

        # ...or for an inline style second part
        elsif @scanner.scan( InlineLinkRegex )
          url = @scanner[1]
          title = @scanner[3]
          rel = @scanner[5]
          @log.debug "  Found an inline link to %p" % url

          text += %{<a href="%s"} % escape_md( url )
          if title
            title.gsub!( /"/, "&quot;" )
            text += %{ title="%s"} % escape_md( title )
          end
          if rel
            rel.gsub!( /"/, "&quot;" )
            text += %{ rel="%s"} % escape_md( rel )
          end

I also added the following to my Mephisto theme layout, in the head section:


   <!-- Photoslice -->
   <link rel="stylesheet" type="text/css" href="/javascripts/photoslice/style.css" />
   {{ "photoslice/functions.js" | javascript }}

Once again, Ruby is awesome. And so is Markdown.


Uncategorized , , , , , , ,

Finding bad JPEGs with Xorg hacks in Ubuntu

November 25th, 2007

So, I have all these JPEGs, and I want to know which ones are corrupt (specifically, ones that end prematurely). qiv will spit out the following to STDERR when it finds one:


Premature end of JPEG file

So, this is nice, except it’s entirely unscriptable. The solution I found was using the following script to the display the images in sequence:


perl -e 'for(glob("*.png *.jpg")){$output = `qiv "$_" 2>&1;`; if($output =~ /Premature/){print $_, "\n";}}'

All this does is mix STDERR with STDOUT for a qiv of the file, and check the output for the word “Premature”. If it finds the word, it prints the filename. Simple.

The only problem is that qiv doesnt have a way to just check whether a JPEG file is corrupt (and if there is a command line utility that does, please let me know). To make it go thru the list, I wrote this little gem:


while(true); do xte "key q"; done

All this does is send the q key to the Xserver infinitely. All I have to do is put focus on the first qiv window to make it and all subsequent qiv windows receive q’s. So, just run it, and click on the window. Then there are lots of flashes, and eventually that perl script will print out the names of the bad files. It’s totally ghetto, but it’s the best I’ve got right now. The point of this post is to hopefully find new ways to do this more programmatically.

Uncategorized , , , , , , , ,

Does Alicia Silverstone love meat?

September 21st, 2007

I saw this today, and thought it was hilarious. Basically, this is the main point of the whole thing:

So I decided to have some fun.

Read more…

Uncategorized , , , , , ,

Setting EXIF dates with a loop

September 18th, 2007

Magic EXIF recursive tagging!

Have you ever had your files all nicely nested in directories, but needed to change their EXIF dates? Here’s what I used today to do it:


# Structure like this: 1997/08/Picture.Whatever Maybe Some Spaces.jpg

# Delete the EXIF tags (DONT DO THIS UNLESS YOU KNOW WHAT YOU'RE DOING!)
find . -mindepth 3 -exec jhead -de "{}" \;

# Make Fresh EXIF tags
find . -mindepth 3 -exec jhead -mkexif "{}" \;

# Set the dates according to the Year and Month information in the filenames
find . -mindepth 3 | perl -ne '@a = split(/\//, $_); chomp($_); print `jhead -da$a[1]:$a[2]:01-2007:09:17 "$_"`, "\n"'

This worked wonderfully.

Uncategorized , , , , ,