rescale Ipad screenshots
Hi, lazy Peter:
Screenshots on an Ipad are of size 2048x1536 pixel. On my website they have to be a width of 640 px . So it was downloading (email) downloading on PC , changing size , saving and then using a picture., possible but 'time-consuming. So use Pythonista, Peter! Done as follows:
#! python3 import photos as ph def scshnr(nr): sc = ph.get_screenshots_album() img = sc.assets[-nr].get_image() #see minus, telling from last photo return img def resizeimg(nw, von, bis): """ resize photos from: von until: bis new width = nw """ for i in range(von, bis + 1): img = scshnr(i) W = img.width H = img.height #print((W,H)) hdw = round(1.0 * nw/ W, 3) #print(hdw) nh = int(H * hdw) #print(nh) res = img.resize((nw,nh)) #res.show() ph.save_image(res) resizeimg(640, 1, 1) #resize to widht 640 (from 1 to 1 : means only the last img) print('OK') #message in the Console
Pleas suggest a better way to show the code, if it does not show indented here ;-)
Tap </> at top and insert your code between the two generated lines of ```
@PKHG , @ccc shared a tip sometime ago. On IOS, settings->keyboards->text replacement.add an entry ",,," just 3 comas and the replacement text to be 3 backticks ```. Makes it easy to add code to the forum. Can also use the </> btn also, I think the other way is faster. The nice thing about the text replacement, is that it's not usual your will type 3 commas in a row.
@PKHG, in Pythonista, in the Tools (wrench) menu, Share, Gist. Then only put the link here. Easy for people to copy all or download your code.
Also, if you cannot use Pythonista, there are tons of free resizing apps in the store. No need to go to PC; at least I have not had any need for the past year or so.
Gists are nice, but ...
- can be updated, context can be lost, unless you link to specific revision,
- can be deleted, forum link points to void,
... it’s better to insert code here if it’s not too long.
thanks Mikael ,,, done meanwhile, as anonymous (next time as PKHG) but how will it be found now?
@PKHG , after you share a gist, the URL is copied to the clipboard. A HUD comes up telling you so. You can use the link item here and paste in the gist's URL.
I made this test gist. Anonymous, but not private settings.
Should would if you click the link, but its not inline as @zrzka points out.