Editorial Workflows

Save Photo Copy

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Takes first image from the clipboard and saves to document directory using the current document's filename and saving as a jpg. Inserts an <img> tag and sets the width. The width default is 640px and the height is set to aspect ratio.

Shared by: rpmik

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import editor
import clipboard
import os
from PIL import Image

img = clipboard.get_image()
if img == None:
	print "No image in the clipboard"
	workflow.stop()
else:
	img_path = editor.get_path()
	img_dir, fn = os.path.split(img_path)
	fn=fn.replace("md","jpg")
	output_path = "./"+fn

	#from https://opensource.com/life/15/2/resize-images-python
	baseheight = 640
	hpercent = (baseheight / float(img.size[1]))
	wsize = int((float(img.size[0]) * float(hpercent)))
	img = img.resize((wsize, baseheight), Image.ANTIALIAS)
	img.save(output_path)
	workflow.set_output(output_path)
	
Replace Selected Text ?
Replacement Text
<img src="Input" alt="Photo" style="width: 640px;"/>