Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Render HTML into image?



John,
I had to work with some web pages that didn't have good tags to
Parse as RTF -- or anything else in JavaScript. You couldn't tell headline
from body copy. Sorry if this is a bit long, but being a NewBie -- I
appreciate it when someone gives me the "work flow", and I hope this is
helpful.

[moving on]

So I decided to use Automator (had some good built-in routines so I didn't
bother with ActionScript for this task) to grab the pages from the URLs
before my QuartzComposer file would display them (inside of Ical -- which
saved me from having to get into the lore of managing multiple events each
day using Lingon to edit LaunchD. Ical is fine (but shame on Entourage for
telling me how to capitalize iCal) as long as you allow for scripts that
hang [by using "try with timeout set to 120". Everything runs fine -- but I
keep getting error messages that ruin the screen telling me that something
that ran didn't work.

I used a routine for Automator that turned a web page into a PDF -- which is
better than the image capture I was going to do, because I get all the
pages. One improvement I would make to this -- 1) I found a way to
asymmetrically crop an image from the command line (everything seems to want
a margin), and 2) you don't have to split PDFs into images to load them, it
turns out reading this blog that you can load a PDF as a movie, and use the
frame controls to go to a page -- who'd a thunk it, right? It's like the
capability was hidden.

[I'm also new at this, and don't know how to put an image in the reply]

I have a master Automator script to go through about 10 websites for the
daily news and do cleanup on old downloads. Here are the functions grabbing
the headlines;
1) [remove temp files from folders]
2) Get Specified URLs
3) Download URLs as PDFs
4) Get Specified finder Items
5) Render PDF Pages as Images (PNG, 100 dpi)
6) Crop Images (to Dimensions 810x 1040, width & height - No Scale)
-- or you can use the obscure; proppercropper.action to crop where you want.
-- 
http://turtlehead.co.uk/macintosh-toys/osx-tiger-automator-propper-cropper/
7) Render PDF Pages as Images (JPEG, 100 dpi)
8) Rename Finder items (Make Finder Items Names Sequential)
9) Move Finder Items [to a folder where my Quartz Composer file looks for
them.

But parsing each page to an image from the PDF still works great, because
then I can trim dead space. [If I wanted more performance, I would have
ActionScript call the command line and use many of the image routines
available -- but ActionScript is quicker than the URL calls and the finder
response -- so it isn't much of a bottleneck. ]

Here's another capable image editing app for AppleScript;
http://www.yvs.eu.com/imagine.html

After that I display the images, I figured out a nice trick of "scrolling"
The image as though it were in a mask, but instead I use the "crop"
function-- thus I eliminate extra pixels and get fairly smooth performance.
I'm assuming that the crop is faster than masking with another image to
define the image we see [maybe others could weigh in on that]. See "Picture
2.gif" if it makes it through this email. The iterator traverses the image
from top to bottom - the height of the page. I suppose I could tweak this by
making it slow down for taller pages -- but I was driving this with a master
timer [and at the time, I was just learning that you couldn't "export" a
variable from a Macro-Patch that rendered an image -- boy was that a huge
undocumented issue at first.]

There might be a way to have QuartzComposer call an ActionScript or better
yet Python or Ruby if you know it -- hopefully someone can mention how to do
that without breaking out Xcode. I just found it easier to have iCal call my
scripts and then set what my screensaver is (actually, I set my background
to a QuartzComposer file so that I can have other widgets and the like
layered over to add a lot of functionality to my kiosk). Not being a
full-fledged Apple programmer, I've yet to break out of the sand box with
quartz beyond fetching some web data (or local files) -- no calls the other
scripts.

The web page takes up most of the screen--thus everything is legible, with
rendered lighting (borrowing from iTunes album visuals), plus the usual
reflection -- this all spins around before being replaced with the next
image. Performance is pretty good on a Mac Mini. Trying to do this without
pre-fetching the graphics would be hit and miss at best. I can deal with
failed downloads and recalcitrant URLs better in external apps like
AppleScript [boy, if they could just change that from the clumsy not-easy
human speech paradigm to something like ActionScript/ECMA standard I would
be very happy with it -- OK, and a few other real-world improvements].

Regards,
Mark Johnson


>>Greetings everyone... long-time reader, first-time poster.

>>I'm trying to render a web page into an image and use it in a comp -
>>kind of like the RSS Feed, except with layout and images. It'll only
>>be used to display custom pages, so clipping/scaling is not an issue.
>>I suspect it can be done with WebKit and some Objective-C code, but
>>I'm hoping that it's already out there.

>>Anyone tried it, or done it?

>>(I could probably do it with some external code that renders the page
>>to a static image and then use Folder Images, but I'd eventually like
>>to try video on the page too).

>>Thanks,
>>John

Attachment: Picture 2.gif
Description: Binary data

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.