Files
Lee Hanken 7c8efd2228 Initial commit: HPR Knowledge Base MCP Server
- MCP server with stdio transport for local use
- Search episodes, transcripts, hosts, and series
- 4,511 episodes with metadata and transcripts
- Data loader with in-memory JSON storage

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 10:54:13 +00:00

110 lines
9.6 KiB
Plaintext

Episode: 2730
Title: HPR2730: Resizing images for vcard on Android
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr2730/hpr2730.mp3
Transcribed: 2025-10-19 15:49:40
---
This is HPR episode 2,730 entitled, Recycling Images for V-Card on Android.
It is hosted by Ken Fallon and is about 11 minutes long, and carries an explicit flag.
The summary is, automating the steps needed to get images formatted for V-Card important on Android phones.
This episode of HBR is brought to you by AnanasThost.com.
Get 15% discount on all shared hosting with the offer code HBR15, that's HBR15.
Better web hosting that's honest and fair at AnanasThost.com.
Hi everybody, my name is Ken Fallon and you're listening to another exciting episode of Hacker Public Radio.
I want to maintain a set of V-Cards that I can share with the kids, contact information for family and relatives.
With V-Cards though, when I transferred them over to the various different phones, some of them copied and some of them didn't.
And I was, quote, bit my head against a wall trying to figure out what the problem was.
Common denominator was that all ones that transferred did not, the ones that transferred did not have photos, although there were some that did have photos.
And when I compared, I eventually narrowed it down to the photos.
And when I compared, I couldn't see any differences in size of the photo images, the format of the images, etc.
And then a bit of searching identified that it all came down to the aspect ratio.
The aspect ratio needs to be one to one.
Not only that, it needs to be either 96 by 96 for the first version of Android, ICS, 4.0, 256 by 256.
And then in 4.1, it was 720 by 720.
So when I tried various ones of these, the 96 squared and the 256 squared worked fine, but the 720 one didn't work on all the phones.
So and also the image quality wasn't that much better between the two.
The image quality between the 96 and the 256 one was significantly better, but not so bad that you still couldn't transfer the files.
So I decided to choose 256 by 256 as the standard format for all the images.
Now, I have about 30 people in the immediate family on both sides of my wife's and my own family.
That I wanted to have contact information for, and I didn't want to be dragging all of these into color paint and start editing them there.
So the steps if you were to do it in color paint are the Gimp or other photo manipulating software would be to import the image.
Then you select the image and then do a scale, smooth scaling, maintaining the aspect ratio.
And you would need to pick 256 yourself, 256.
So as they whichever is greater, the height of the width set that to 256 and then the other one will scale down accordingly.
Okay, so then you will have an image that's either 256 wide and something less tall or 256 tall and something less wide.
Depending on whether it's a portrait or landscape of the person, you probably portrait more than likely.
Then you will go increase scale canvas, so increase the canvas size and set that so that it doesn't respect the aspect ratio.
So you're not stretching or squashing the photos of the people and set the color to the background color to white and then center the image in the center.
That is a lot of steps for more than five photos or reckon.
So it came into some sort of tool on the command line that would make it possible to automate all of these.
So I also want to do it for all the photos that have collected from people who work and stuff as well.
Because it's handed a face, gives me a lot more recognition than just somebody's email address or names.
So command line tools from manipulating images on Linux, you're immediately thinking image magic, I'm guessing.
Well, I will prefer to use graphics magic and everything I do here with image magic is available in graphics magic and vice versa.
So if you wish to use image magic, that's absolutely fine.
You'll find graphics magic is probably already installed on your system as it tends to be and it's I believe more maintained.
There is a good episode on floss weekly about graphics magic, so you can check that out there.
So the things that we need the commands to do all of this are in the show notes for this.
So I'm not going to bore you too much about it and I've done a worked example of from a photo of Linus Torvals, which I work through the various different steps on what the various different options will do.
And that's in the show notes there.
The one tool on image magic is called identify and then you can put the name of a photo.
So identify Linus Torvals and .JPEG and that will give you some basic information about the tool in graphics magic.
All the commands that you would normally have in image magic are behind the tool itself.
So gm space identify Linus Torvals.JPEG is the same as the equivalent to the image magic web.
I actually find that tidier because everything's within the one.
So some of the things that when resizing an image, you might assume that you would use the simple dash size 256 by 256.
That one is actually used when you're creating an image from scratch.
So when you want to programmatically create an image like or modify a canvas or something.
So if you just use that on a larger image like a photo quality one, what ended up happening was that I ended up with an image that was the maintain the aspect ratio,
it was actually 366 by 509 nowhere near the 256 by 256.
But that said, when I was reading about this apparently that size thing is used as a hint when doing the other manipulations that I will be using later on.
So I left it in to be honest I didn't see a massive difference when I didn't use it but I left it in better safe than sorry.
Now some of the things that you need to do the order of which you put them on the command line for graphics magic is important.
The last one specifically needs to be the last one I'm going to discuss will be the first one that I've got.
I'll go through the options and then at the end I'll give you the correct order.
So the command you actually want to use to scale an image the way that I want is actually resize.
So resize 256 256.
So what that does is it will resize it down so that if either the whichever the biggest is the width or the height will be under 256.
And once I did that with the image is scaled it down to 184 by 256.
So the width is 184 by 256.
So that's one to one.
Now the next command I used was the extent command EXTNT.
And what that does is will take the image and it'll increase the canvas to 256 256 which is exactly what I want.
But because the height hasn't changed what it ended up doing was adding a little bit of white space on the right
side of the image. So if you imagine the big cropped image on one side and then you have this big white border on the other side.
So in order to get around that you can use the gravity command.
So you have north, south, east, west, northwest.
And then the one that I'm looking for is center.
And what that does is it will position the image right bang in the center of the canvas and increase the canvas around this proportionally.
So that left two white borders on either side.
So that gives a nice balanced look when somebody calls you on the phone.
The image comes up and you don't really notice the two white bands.
Difficult enough in the show notes to see it.
And I'm interested to see how Dave is going to get around this when he's uploading it to archive.org because it's got a border on it.
So white border.
I put a HTML border around the image so that you can see.
So you can see this padding because you're not going to see it if the generic white border white canvas and white border.
So the entire command is GM convert space gravity center.
So that one needs to be there first space dash size 256 256 don't even know if you need that.
Space the source image in this case linus torvals.jpg space and now they the stuff that we want to do dash resize 256 256 dash extent 256 dash 256.
And then I also put in plus profile space double called asterix double called space linus torvals.
underscore 256 x 256.jpg.
And that will produce the image the last profile thing what it does is it strips any profile information that's in the picture and just gives you.
Just tells the computer not to do any messing with it profile information allows you to give hints to the screen to just to say what the color.
Information is going to be like to get color record pictures, but as this is going to be in a v card.
I want as little information in there as possible.
So what you can do I also put it in a a little script in the show notes for image in asterix jpg do for size in 96 by 96 256 by 256.
720 by 220 do Jim convert all the rest of that replacing size and image and that basically will give you.
If you put it into directory to create three thumbnail files of any image that you happen to have in there and you can see which ones work best for you.
Okay, that's pretty much that.
Thank you for listening. I hope this was of some use to you.
And tune in tomorrow for another exciting episode of hacker public radio.
You've been listening to hacker public radio at hackerpublicradio.org.
We are a community podcast network that releases shows every weekday Monday through Friday.
Today's show, like all our shows, was contributed by an HPR listener like yourself.
If you ever thought of recording a podcast then click on our contribute link to find out how easy it really is.
HackerPublicRadio was founded by the digital dog pound and the infonomicum computer club and is part of the binary revolution at binrev.com.
If you have comments on today's show, please email the host directly, leave a comment on the website or record a follow-up episode yourself.
Unless otherwise stated, today's show is released under creative comments, attribution, share a life, 3.0 license.