Re: Converting WebView to JPEG
Re: Converting WebView to JPEG
- Subject: Re: Converting WebView to JPEG
- From: development3 <email@hidden>
- Date: Fri, 30 Mar 2007 10:46:12 -0600
Never mind, right after sending this I ran across a post on the list
the showed me how to do this.
http://lists.apple.com/archives/cocoa-dev/2004/May/msg01315.html
I had to turn it first into a TIFF representation, then get a JPEG
representation from that. Then I could save it. Also I was able to
set the size with this code;
[image setScalesWhenResized:YES];
[image setSize:NSMakeSize((float) 100,(float) 100)];
After I got the image from the view.
Thanks,
Scott
On Mar 30, 2007, at 10:03 AM, development3 wrote:
I was hoping I could get some help here. What I need to do, is take
a WebView that I have, create an Image from the WebView, and then
convert it to
a JPEG. I have some code that will create a PDF from the WebView,
and then save it. But the problem I found there was I can not
reduce the the PDF
image size to a thumbnail that I need 100x100. I have tried several
things but have had no luck in figuring that out. So I thought,
alright maybe a JPEG
would be easier. But I can not figure out how to get the
NSBitmapImageRep from the WebView?
Here is what I have to get the a PDF image from the WebView
pdfData = [webView dataWithPDFInsideRect:[webView bounds]];
pdfRep = [NSPDFImageRep imageRepWithData:pdfData];
[pdfRep setSize:NSMakeSize((float) 100,(float) 100)]; // <-----
THIS DOES NOT WORK
if ( [[pdfRep PDFRepresentation] writeToFile:[testString
stringByExpandingTildeInPath]
atomically:NO] )
{
NSLog(@"getURLImage -- Image written out");
}
else
{
NSLog(@"getURLImage -- Image NOT written out");
}
But I can not figure out how to get a NSBitmapImageRep from the
WebView. I don't see a way just to get Bitmap data from the WebView
(NSView). Is there
anyway to do this? I have looked through the Cocoa List archives
and tried to figure this out, but I feel like I am just going down
the wrong road. Maybe If I could figure out
how to save the PDF at 100x100, this would solve my problem.
Thanks in advance,
Scott
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40bitblasters.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden