• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sharpen Image for an entire PDF?
#1
G'day all,
I now have several multi-song PDF's imported via csv.  The most recent has 958 songs across 274 pages.  Took me AGES to create that csv file!

Anyhow, the original source that was scanned is march card sized and there can be anything from 1 to 5 or 6 songs on a single page.  As you can imagine, with a paper source this small and cramped, the scanned images are not amazing.  That said, they're not terrible, but they are certainly improved by the Sharpen Image feature of MS.

Unfortunately, I can't see any way to apply Sharpen Image to the entire PDF without doing every song individually...

Is there a way to apply Sharpen Image to a PDF, or at least to multiple songs in a global, or batch, fashion?
You're only paranoid if you're wrong  Cool
I'm using an Onyx Boox Tab X
Reply
#2
You can use https://imagemagick.org to fix your pdf file.

You might have to export each page to a separate image first for the best results.

Your workflow would look something like this:

pdfimage myfile.pdf i

mogrify -sharpen 0x1 i-*

You might want to experiment with the sigma value for the best result. It can be any floating point value from  .1  for practically no sharpening to 3 or more for severe sharpening.  0.5 to 1.0 is usually rather good.

You can make the images back into a pdf file using various methods; I usually do it like this:

for i in *; do convert "$i" "$i".pdf; done
pdfunite i*.pdf endresult.pdf

convert can create the pdf file from all of the images at one time but sometimes it seems to overrun the available memory when it's doing that so it's usually better to just make each page into an individual pdf and combine them at the end as shown above.
If you're a zombie and you know it, bite your friend!
We got both kinds of music: Country AND Western
Reply
#3
Hi Mike, Frank, Lawrie,

I would like to second the request for an option to use the "sharpen image"-feature across multiple or all songs. Of course your tip, Frank, can also be helpful, but as there is already a built-in feature to sharpen images inside MobileSheets it would probably be easy to modify it.

I would imagine it could have a second option like "keep activated across songs in setlist" or "keep activated for all songs" - the wording could probably be more elegant. Also perhaps it would be possible to have the icon in the quick action box that you, Mike, said you might upgrade sometime soon. It could be a toggle between off, one song (orange and a little 1) and all songs (orange and a little a?), and a long press would lead to the ui for adjusting the sharpen value.

It wouldn't be a very important feature for me, but a "nice to have", if it is not too complicated to implement.
Reply
#4
I just want to clarify something - are you referring to the Sharpen option that shows up when a song is loaded, you bring up the song overlay, tap the second icon at the bottom left and tap "Sharpen"? Or are you referring to the recently added "Image Correction" feature? The sharpen option is pretty lightweight and it would be easy to either provide an option to apply the sharpen setting to all songs in the library or have an override of some kind to automatically apply it to all songs. Adding a way to apply the image correction to every file in the entire library is not easily doable with how the third party software works that I'm utilizing. I have to rebuild every file with that feature, and it requires rendering every page of every file at higher resolution (to prevent a loss in quality) which takes a long time. Doing this to an entire library would take a very, very long time.

Thanks,
Mike
Reply
#5
Hi Mike,

I meant the first thing you are describing, the icon in the song overlay. It is nice to hear, that an option would not be complicated to implement.

I currently mostly use the iPad-version so I haven't had a chance to check out the new features yet. But I understand and agree that the third party software doesn't seem to be a practical solution for this suggestion. However I am already exited to check out all the options as soon as the iPad version becomes available Smile
Reply
#6
(11-20-2023, 07:42 AM)Zubersoft Wrote: I just want to clarify something - are you referring to the Sharpen option that shows up when a song is loaded, you bring up the song overlay, tap the second icon at the bottom left and tap "Sharpen"? Or are you referring to the recently added "Image Correction" feature? The sharpen option is pretty lightweight and it would be easy to either provide an option to apply the sharpen setting to all songs in the library or have an override of some kind to automatically apply it to all songs. Adding a way to apply the image correction to every file in the entire library is not easily doable with how the third party software works that I'm utilizing. I have to rebuild every file with that feature, and it requires rendering every page of every file at higher resolution (to prevent a loss in quality) which takes a long time. Doing this to an entire library would take a very, very long time.

Thanks,
Mike

Hi Mike,
what I had in mind was the first alternative.  IE the sharpen option from the song overlay.

I actually wasn't aware of the "Image Correction" feature.

Additionally, I wasn't thinking of trying to use it on my entire library(ies) as most of my PDFs are fine and don't need sharpening.  What triggered the question was the import mentioned in my original post - 958 songs across 274 pages in a single PDF.  An option to sharpen on a PDF by PDF basis would be great, an option to apply on a collection basis might also be useful.

Where do I find the "Image correction" feature, and does it work on PDFs or just images?

Thanks mate.
You're only paranoid if you're wrong  Cool
I'm using an Onyx Boox Tab X
Reply
#7
Hi Frank,
thanks for pointing me to ImageMagick.

I will explore the possibilities and what it might be able to do for me.
You're only paranoid if you're wrong  Cool
I'm using an Onyx Boox Tab X
Reply
#8
Long press a song to select it on the library screen, then tap "Edit Song" in the action bar. Go to the Files tab, tap the three dots next to the file in the list and tap "Image Correction". MobileSheets is going to need to first render an image for every page in the entire PDF. It then will process every one of those rendered pages to apply the image correction to it. Just be aware that if you do this with a 274 page PDF, for example, it's going to take an extremely long time to process every page. 

Mike
Reply
#9
Hi Mike,
in this particular instance, this sounds like I'd also end up with 274 separate image files...  Or does MS then aggregate the image files back into a single file?  Or back into the PDF?

How long is "Extremely long"?  are we talking hours or days?
You're only paranoid if you're wrong  Cool
I'm using an Onyx Boox Tab X
Reply
#10
MobileSheets will combine the files back into a single PDF at the end.

As far as the time, it depends on your device and the speed at which the file can be read (and the DPI of the images in the file), but I would estimate it could take somewhere around 15 seconds per page, so anywhere from 45 to 70 minutes.

Mike
Reply
#11

Thanks Mike, good to know. The more I learn about MS, the more I like it.   Cool


PS found this message in drafts...  Somehow it didn't get posted when I first wrote it.
You're only paranoid if you're wrong  Cool
I'm using an Onyx Boox Tab X
Reply
#12
(11-20-2023, 09:01 AM)Zubersoft Wrote: Long press a song to select it on the library screen, then tap "Edit Song" in the action bar. Go to the Files tab, tap the three dots next to the file in the list and tap "Image Correction". MobileSheets is going to need to first render an image for every page in the entire PDF. It then will process every one of those rendered pages to apply the image correction to it. Just be aware that if you do this with a 274 page PDF, for example, it's going to take an extremely long time to process every page. 

Mike

Hi Mike,
finally had some time to set aside for this big PDF only to find that t'ings ain't what dey appear...
So, to confirm, my process was:
  1. Change to the relevant library
  2. Open the collection that uses the 274 page PDF
  3. Long press a song (any song... - happened to be the 55th one)
  4. A check mark appears against the song
  5. Press "Edit Song"
  6. Press Files tab
  7. The correct PDF is listed.
    The display shows:
    Page Order: 13
    Number of pages: 1
    Page slider says 1/1
    seems OK
  8. Press the "3 dots" and select Image Correction
  9. Message "Generate pages 1 of 1 appears, image is cleaned up, and stops there...
    I was expecting it to process every page - did I get that wrong?
  10. press 3 dots at the top and select cancel and screen reverts to the previous one.
  11. *Not game to save anything just in case... So press cancel again and discard changes.

Tried this several times with various songs on different pages and always got the same result.  
Have I made any errors in the process?

* The reason I'm not game to save anything as the very first time I tried this I used the first song in the list and did save.  After that the 74Mb PDF was about 500k but it took me a while to notice...  Every song I tried to select was on the first page 'cos that was all that was left in the PDF.
I ended up having to delete the songs from the database, replace the PDF, and the csv for good measure, and reimport.  This took a couple of goes too before it worked  Sad Huh  

Could the PDF be faulty even though MS correctly selects pages when using the PDF for performance (and does again now I replaced it after the screw up)?

Thanks Mike
You're only paranoid if you're wrong  Cool
I'm using an Onyx Boox Tab X
Reply
#13
That means that MobileSheets is respecting the page order when doing the image correction, which is a good thing, but it is replacing the existing PDF when this occurs without a warning which is a bad thing. I will have to add a warning for that. What you need to do is have a song that uses the entire page range of the PDF (you can do this by copying one of the existing songs and changing the page order to "1-274" (replace 274 with whatever the last page is), and then applying image correction to that. That will process every page in the entire PDF, and since all the other songs share the same PDF, the image correction will work for all of them at once.

You can always create a library backup under Settings->Backup and Restore->Backup Library before experimenting with any features, and you can also use the swap file feature (or replace the file manually) if the shared PDF needs to be reverted for any reason.

Sorry for the lack of clear directions on my part.

Mike
Reply
#14
I've reworked the code now so that if you apply image correction to a song using just a range of pages from a larger PDF, it just replaces the pages in the existing PDF instead of overwriting it. You'd still have to do what I suggested to apply the image correction to the entire PDF at once, but this will prevent users from fixing one page in a PDF and breaking other songs that use the same PDF.

Mike
Reply
#15
Hey Mike,
thanks for clarifying things.

Needing to have a "song" that uses all the pages in the PDF in order for image correction to modify every page makes perfect sense now I think about it.  Still learning this wonderful product!

The code change to replace modified pages rather that replace the entire PDF when a subset is used is a good correction.

FWIW, it only took a few minutes to do the entire PDF - perhaps 4 or 5.  I was expecting a much longer wait but it was exporting pages at a rate of maybe 3 or 4 per second.  The correction process was slower as you would expect, maybe 1 1/2 to 2 per second, and stitching the PDF back together seemed to be almost instant.

FWIW I'm using an Onyx Boox TabX

Again, thank you.

PS  Just to be difficult, I'm not sure anything actually changed...  I'm going to recheck my process to make sure I didn't miss anything.
You're only paranoid if you're wrong  Cool
I'm using an Onyx Boox Tab X
Reply




Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2024 MyBB Group.