• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ChordPro and images
#16
Mike, what if we invent a way to embed the image in the ChordPro file?

For example (just a proposal):

Code:
{image id=img1 center}

and at the end of the ChordPro file:

Code:
##image: id=img1 type=jpg width=600 height=84 enc=base64
# /9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEP
# ERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4e
# Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCBMbC7gDAREA
# ...
# EBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ
# EBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEH//2Q==

MSPro would then only support these type of images, and I think it would be reasonably straightforward for Companion to turn a file link into an embedded image. By 'hiding' the image data within #-comments it will not get in the way of most other tools.
Johan
www.johanvromans.nlwww.hetgeluidvanseptember.nlwww.howsagoin.nl
Samsung Galaxy Note S4 (T830) 10.5", Android 10.0, AirTurn Duo & Digit.
Samsung A3 (A320FL), Android 8.0.0 (emergency).
Reply
#17
That's certainly an interesting idea. I'm up for trying to support that. So just to verify, you think I should convert any image links to embedded images instead of giving the user control over that, right?  If the relative image link is broken, then I would do nothing when the file is imported or processed.

Thanks,
Mike
Reply
#18
Precisely. And only Companion will have to deal with the actual files. When sending the song file to the device, the file names are gone and the data is included. No tablet editing of filenames that can go wrong, no additional files on the tablet that must be kept track of.

I've made a proof-of-concept implementation in the ChordPro program that seems to work well. It may need another night sleep, though.
Stay tuned.
Johan
www.johanvromans.nlwww.hetgeluidvanseptember.nlwww.howsagoin.nl
Samsung Galaxy Note S4 (T830) 10.5", Android 10.0, AirTurn Duo & Digit.
Samsung A3 (A320FL), Android 8.0.0 (emergency).
Reply
#19
Okay, this is how far I've got.

The syntax for the {image} directive has a new argument 'id=XXX' that specifies a known asset identified by the id 'XXX'. 'XXX' may be an arbitrary identifier.
For the {image} directive, the asset should be an image.
How the relation from 'XXX' to the image is established is up to the application program.

One way to define an asset is with a special file comment (not to be mistaken with a ChordPro {comment}). Such a comment looks like:

Code:
##image: id=XXX

Minimal, or with all options:

Code:
##image: id=XXX src=im.png type=png width=1341 height=340 enc=base64

which is immedeately followed by the data for the image, base64 encoded, in lines that start with "# " (pound space).

Code:
# iVBORw0KGgoAAAANSUhEUgAABT0AAAFUCAIAAABp2w/aAAAABGdBTUEAALGPC/xhBQAAAER0RVh0
# U29mdHdhcmUAWFYgdmVyc2lvbiAzLjEwYS1qdW1ib0ZpeCtFbmggb2YgMjAwODEyMTYgKGludGVy
... many more ...
# AAd0SU1FB+AEBwgjAAJ9CYIAAAAedEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1QCpgy
# LukAAAAASUVORK5CYII=

So when the user presents a ChordPro file with one or more {image}s, Companion can change the {image} directives and include the image data as shown above. For people that do not use Companion, there are other tools that can assist.

When a song is edited in MSPro, the asset data can be omitted to not clobber the view and/or slow down the editor.

What do you think?
Johan
www.johanvromans.nlwww.hetgeluidvanseptember.nlwww.howsagoin.nl
Samsung Galaxy Note S4 (T830) 10.5", Android 10.0, AirTurn Duo & Digit.
Samsung A3 (A320FL), Android 8.0.0 (emergency).
Reply
#20
I think that all sounds great. I'll just have to make sure there are easy ways to add or remove images, especially if I'm hiding the encoded image content from the user in the editor.  It's easy enough to add options for this in the tablet app editor, but the companion app doesn't really have a great editor at the moment for chord pro files. So I will need to start adding more  capabilities. I suppose if I parse the file after the user has edited it and they have removed the ##image line, then I can just remove any image data associated with the given id. So maybe an explicit option to remove an image isn't really needed. Adding an image is as simple as listing the name of the image file to include, so users can either write that themselves or I can add a simple option to add an image that lets them use a dialog to enter the data for the image (so that they don't have to memorize all of the supported parameters).

Thanks,
Mike
Reply
#21
(11-23-2018, 02:02 AM)Zuberman Wrote: I suppose if I parse the file after the user has edited it and they have removed the ##image line, then I can just remove any image data associated with the given id.

I assume you mean "... have removed the {image...} line"? If the user removes an {image} line, the corresponding image data can be discarded (provided it is not used by another {image} line using the same id).

Quote:Adding an image is as simple as listing the name of the image file to include, so users can either write that themselves or I can add a simple option to add an image that lets them use a dialog to enter the data for the image (so that they don't have to memorize all of the supported parameters).

Right.

BTW it still would be possible to put an ChordPro file on the tablet that contains an {image src=...} but then it is completely the responsibility of the user to ensure the image file is also on the tablet, next to the ChordPro file. So w.r.t. files, MSPro would only need to deal with this very trivial case.
Johan
www.johanvromans.nlwww.hetgeluidvanseptember.nlwww.howsagoin.nl
Samsung Galaxy Note S4 (T830) 10.5", Android 10.0, AirTurn Duo & Digit.
Samsung A3 (A320FL), Android 8.0.0 (emergency).
Reply
#22
Will this cope with multiple images ?
Just playing devil's advocate; I wouldn't use this feature.

Geoff
Samsung Galaxy Tab A6
Reply
#23
You can have multiple {image} directives, hence multiple images.
Johan
www.johanvromans.nlwww.hetgeluidvanseptember.nlwww.howsagoin.nl
Samsung Galaxy Note S4 (T830) 10.5", Android 10.0, AirTurn Duo & Digit.
Samsung A3 (A320FL), Android 8.0.0 (emergency).
Reply
#24
Hi!

We are currently facing the same topic with our band, so I found this thread. Are there any news regarding that request?
Or is it already implemented and I completely missed it? Big Grin
Reply
#25
I haven't had time to implement it yet unfortunately. It's still on the list of things to do (it's a pretty big list). 

Mike
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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