View Single Post
Old 05-11-2017, 10:46 PM   #3
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
Is this just going to be for your own personal usage? Or is this for an actual book?

Was this a bunch of inline images instead of Arabic text? (I know I have run across similar problems with crappy conversions of Greek text.)

As you know, trying to UPSCALE things will result in some subpar images... but if you just needed something a little quick/dirty, I dabbled in this for a little and came up with this basic workflow.

Step 1

Original Image:

Name:  test2.png
Views: 993
Size:  762 Bytes

First you upscale the image:

Code:
convert test2.png -scale 1000% test2[Scaled1000].png
Click image for larger version

Name:	test2[Scaled1000].png
Views:	357
Size:	2.3 KB
ID:	156674

Note: You can insert any % there. 1000% makes it 10x larger.

Step 2

Then you can adjust the contrast slightly:

Code:
convert test2[Scaled1000].png -contrast-stretch 3% test2[ContrastTweak3].png
Click image for larger version

Name:	scale[ContrastTweak3].png
Views:	338
Size:	2.2 KB
ID:	156675

Note: You can insert any % there. I found that anywhere from 1-5% seemed decent. Going beyond that distorted the text too much.

Step 3

Then you can scale the image down:

Code:
convert test2[ContrastTweak3].png -scale 40% test2[ScaledDown40].png
Click image for larger version

Name:	test2[ScaledDown40].png
Views:	341
Size:	1.3 KB
ID:	156676

Note: You can use whatever % or size you want here. This results in a final image that is 4x larger.

Step 4

If you wanted to convert on an entire folder of PNGs, just go to the folder and run this:

Code:
convert *.png -scale 1000% -contrast-stretch 3% -scale 40% -set filename:fname %t_tn +adjoin %[filename:fname].png
Note: If you have a ton of images, probably better to run mogrify or come up with some sort of batch file. I read about the convert -set filename method here: https://www.imagemagick.org/Usage/ba...ogrify_convert

You could also probably introduce more steps in between (different resizing filters, etc. etc.), but I am not that familiar with that. Most of the time I am just using Imagemagick to clean up speckling in scans. :P

Last edited by Tex2002ans; 05-11-2017 at 11:16 PM.
Tex2002ans is offline   Reply With Quote