Can I change the compression ratio of a JPEG image on travel.state.gov?

When on travel.state.gov's photo editor, I get

Image is overly compressed. Please use a compression ratio that is less than 20:1

Is there anyway to get past this screen in the application given a jpg file? Can I open it up in a gimp and make less-compressed knowing the quality won't be better?

1

1 Answer

We can devise two ways to do this (1) by editing the image, or (2) by editing the JavaScript code.

How it works

Looking at the code, you can see how it's calculated from the definition of

function getCompressionRatio(e, t) { return 3 * e.naturalWidth * e.naturalHeight / t } 

And the call site,

var e = getCompressionRatio(image, imageNumBytes); 

So in the definition e is image and t is imageNumBytes. This is the assumption that the raw image is 3 bytes-per-pixel (TrueColor).

function getCompressionRatio(image, t) { return 3 * image.naturalWidth * image.naturalHeight / imageNumBytes } 

Our options

  1. Editing the image: In order to get a lower "compression ratio" for your image you need only lower the numerator ( 3 * image.naturalWidth * image.naturalHeight ) or raise the denominator by making imageNumBytes (image size) bigger.

  2. Editing the JavaScript code: Alternatively this error is rendered here,

    if (MAX_COMPRESSION_RATIO < e) setUI(UIModeEnum.INIT), setMessageDialog("Your photo has been rejected for the following reason(s):", [{ description: "Image is overly compressed. Please use a compression ratio that is less than 20:1" }]), showControls(!0, ["divMessages"]); 

    In Chrome you can open up the developer console (Ctrl + Shift + J) and run,

    MAX_COMPRESSION_RATIO = Infinity 

    And then the conditional will never trigger and you won't get that error.

8

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like