4

I'd like to come up with a technique for properly posting images on this site on my Macbook using a CLI tool to do the conversion.

This is a sample image that I'd like to make it so that the image is properly sized with a background that's transparent and makes it so that when the image is posted to AskDifferent or other StackExchange sites, that the image will be large enough with a transparent background that no additional tricks are required to center images within posts on these sites.

For reference this is the question that started this: - Have DHCP for Wi-Fi and static IP for Ethernet?

Original

This is the image that without any tricks shows up as left justified

ss

Goal

Another user helped me out and posted a improved version of this image that he used GIMP to merge a transparent background which resulted in this:

ss

NOTE: To be clear, I'm familiar with the techniques covered in posts such as this mSO post on the topic, titled: Is it possible to horizontally center an image on Stack Exchange sites?.

  • You said "... properly posting images on this site" and I have to say that centering an image does not necessarily constitute "properly posting images" since SE doesn't provide for the normal standard methods of centering an image, one could argue that a left justified image is a properly posted image; however, there's no doubt a centered image is ecstatically more pleasing. That said, sans the "properly posting images", it a good question in concept, so +1 for both the A & Q. – user3439894 Apr 23 at 1:57
  • @user3439894 - I meant properly posting from the standpoint of not having to use the   or other workarounds from the mSO Q&A. – slm Apr 23 at 11:07
  • 1
    My definition of proper is left justified text and images. We will have to disagree on that term, but I respect wanting to know how to do this in general, so +1 for the how to. I would encourage a meta question on “if we should do this” if there comes a time when people are editing posts to do this in bulk. – bmike Apr 23 at 11:22
  • @bmike - it's kinda of the problem, we all have our notions 8-) – slm Apr 23 at 12:42
2

Background

I've used ImageMagick in the past to do pretty extensive image manipulations from the CLI. I've written about it extensively here on the Unix & Linux StackExchange site.

Specifically, here's a method I highlighted in this question titled: How to convert, resize and center image with ImageMagick.

Approach

The approach discussed there could be adapted to achieve a solution to this question like so:

$ convert 807634040.png \
    -gravity center \
    -background transparent \
    -extent 678x 807634040-new.png

Resulting in an image like this:

ss

How it works

The convert command is expanding the original image, 807634040.png, so that its width is now 678 pixels. This looks to be the optimal size to use when posting images on SE sites. The -extents 678x means to use the width of 678px but leave the horizontal as whatever it was originally set.

The other options mean to center the image (-gravity center) and to use a transparent background when extending the original.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .