Skip to content

A google app script program that takes image color data, and highlights text to make it resemble said image.

Notifications You must be signed in to change notification settings

QxBytes/image-highlighter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automatic Image Highlighter for Google Docs

Capturebig2

  • Works with any image (vertical images work better than horizontal ones)
  • Works with most text (see below)
  • Any monospaced font works, but you need to count the # of characters per line, excluding the new line
  • Does not work with tabs, lists, bullet point lists, images, tables etc. TEXT ONLY.
  • Does work with spaces/line breaks, however
  • Single spaced for best results
  • This is more of a proof of concept/for fun rather than anything practical

Steps for Preprocessing an Image (A useful tool on its own!)

  1. Download an image, rename it to input.png (if it is a png), and put it in the same directory as color.py
  2. Uses Pillow from pip: python3 -m pip install --upgrade Pillow
  3. Run color.py with python, or, if you have a jpeg or want more features, run with the paramters below:
  4. Run color.py with parameters [TEMPLATE STRING] [FILE NAME] [CHARACTERS PER LINE]
  5. The following selectors are available
    • {a} alpha value from 0-255
    • {r} red value from 0-255
    • {g} green value " "
    • {b} blue value " "
    • {x} x position of this pixel
    • {y} y position of this pixel
    • {bw} 0 if white, 255 if black
    • {ha} alpha hex value (e.g. FF)
    • {hr} red hex value
    • {hg} green hex value
    • {hb} blue hex value
    • \n new line
  6. By default, the code will replace the selector with the actual value for EACH pixel value in the image. The default template is #{hr}{hg}{hb} . Note the space as the values are appended to output.txt with straight concatenation
  7. The default resize is to 70 pixels wide (preserves proportions). The default file is input.png
  8. Using defaults, your output.txt should look like #ABCDEF #123456 #ABC123 #FFFFFF etc.

Steps for highlighting an image

  1. Create a new google doc, and paste the output of output.txt from before. The data may be 50+ pages. Be patient.
  2. In google docs (the doc with text you want to have the image "overlayed" on, not the previously created doc), go to Tools > Script Editor and import the .gs files. Make sure DocUtils.gs is at the top.
  3. Save and return to the original doc. There should be a new menu item next to "Help" in the top bar
  4. Click on the option and it will prompt you. Follow the defaults or change them if you'd like
  5. When it asks for an SRC link, COPY the URL of the google doc you pasted data into earlier in step 1
  6. Wait for 30 seconds and it should highlight everything automatically

About

A google app script program that takes image color data, and highlights text to make it resemble said image.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published