skip to Main Content

I have around 100 sheet music files that contain notes under each other. What I would like to do now is to create one long string of notes.

So there I need to do the following:

  • Cut out specific parts of the .pdf file.
  • Glue them together horizontally

So I have for example this file:

Cut into two parts:

and now I would like to add these together in a line (automatically)

I got the first part covered but have some problems with the second part. Could anybody tell me if there’s a way to load 1 picture and place it of a certain x,y coordinate and then load another picture on another certain x,y coordinate? Think this would require a VBA / Excel equivalent of Photoshop.

Any thoughts?

2

Answers


  1. The trick is to use transform on the images (or a function called translate layer grabbed from the scriptlistner):

      // get all the files to process
      var inFolder = Folder.selectDialog("Please select folder to process");
      if (inFolder != null)
      {
        var fileList = inFolder.getFiles();
      }
    
    // main loop starts here
    for ( var i = 0 ;i < fileList.length; i++)
    {
       // load in image one by one
       // do your stuff and
       translateLayer(x,y);
    }
    
    function translateLayer(dx,dy)
    {
      // =======================================================
      var id2014 = charIDToTypeID( "Trnf" );
      var desc416 = new ActionDescriptor();
      var id2015 = charIDToTypeID( "null" );
      var ref287 = new ActionReference();
      var id2016 = charIDToTypeID( "Lyr " );
      var id2017 = charIDToTypeID( "Ordn" );
      var id2018 = charIDToTypeID( "Trgt" );
      ref287.putEnumerated( id2016, id2017, id2018 );
      desc416.putReference( id2015, ref287 );
      var id2019 = charIDToTypeID( "FTcs" );
      var id2020 = charIDToTypeID( "QCSt" );
      var id2021 = charIDToTypeID( "Qcsa" );
      desc416.putEnumerated( id2019, id2020, id2021 );
      var id2022 = charIDToTypeID( "Ofst" );
      var desc417 = new ActionDescriptor();
      var id2023 = charIDToTypeID( "Hrzn" );
      var id2024 = charIDToTypeID( "#Pxl" );
      desc417.putUnitDouble( id2023, id2024, dx );
      var id2025 = charIDToTypeID( "Vrtc" );
      var id2026 = charIDToTypeID( "#Pxl" );
      desc417.putUnitDouble( id2025, id2026, dy );
      var id2027 = charIDToTypeID( "Ofst" );
      desc416.putObject( id2022, id2027, desc417 );
      executeAction( id2014, desc416, DialogModes.NO );
    }
    
    Login or Signup to reply.
  2. I would do this with ImageMagick which is installed on most Linux distros and is available for free on macOS/OSX and Windows. You just type the commands into the Terminal/Command Prompt.


    At its simplest, you can append two images side-by-side like this:

    magick stave1.png stave2.png +append result.png
    

    enter image description here


    You can append images top-to-bottom like this:

    magick stave1.png stave2.png -append result.png
    

    enter image description here

    The difference is the +/- sign preceding append.


    You can also append two images side-by-side and then append the results top-to-bottom:

    magick stave1.png stave2.png +append 
        ( stave1.png stave2.png +append ) -append result.png
    

    enter image description here


    You can also create a large canvas, of any colour you like (I chose magenta so you can see it on the white StackOverflow background) and splat (a technical term meaning “to carefully position”) your images wherever you like and save that as a PDF like you asked.

    magick -size 1000x400 xc:magenta            
        stave1.png  -geometry +30+10 -composite 
        stave2.png -geometry +550+200 -composite result.pdf
    

    enter image description here

    If you are unfortunate enough to have to use Windows, there are some differences in quoting. The slashes I have at the end of the lines (continuation characters) are represented by circumflexes (^) in Windows, I think. And the slashes preceding parentheses are probably not required in Windows.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search