• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reading NSData from a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading NSData from a file


  • Subject: Re: Reading NSData from a file
  • From: Mike Schrag <email@hidden>
  • Date: Tue, 3 Apr 2007 00:56:26 -0400

What I'm trying to do here is to read back in the results of having run convert on an uploaded image file and making a thumbnail from it. The files are being written only for the convenience of convert, so if I could get out of writing them that would be all the better.

What are you using to convert it? AWT is not too bad for a Java solution.
If by "not too bad" you mean "100x slower than native code" ... It all depends on your needs:

* Slow, Easy, Pure Java, Cross Platform = JAI / Java2D (JAI is not hardware accelerated on OS X)
* Faster, Pretty Annoying, Native, Mostly Cross Platform (portable c) = System call to ImageMagick
* Faster, Way Annoying, Native, Mostly Cross Platform (portable c) = JNI ImageMagick (this has huge memory pitfalls, don't do it)
* Really Fast, Easy, OS X Only = System call to 'sips'
* Super Fast, More Annoying, OS X Only = JNI CoreImage/ImageIO (Brendan posted his version of this on wocode)


When I say 100x slower, I actually mean that. CoreImage and ImageIO are AMAZINGLY fast at this. If you're going to be doing a lot of these, you want that. If you're just doing one here and there, it doesn't much matter. Calling sips commandline is pretty painless and it's using the same API's, though you obviously take the hit of setting up a process. If you're batching you could probably batch up a set of conversions and execute them in one system call.

We use the JNI CoreImage route and Brendan's public code is pretty similar to what we do.

Note that if you go the route of JAI/Java2D, make sure to set - Djava.awt.headless=true or run your app as root, or your WO app will crash as soon as it tries to load an AWT class.

I suppose SWT is an option here as well, though I've never tried to use the image stuff in a non-client app, so I don't know what odd crashy pitfalls await. I believe SWT image loading and scaling is hardware accelerated on OS X.

ms

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Reading NSData from a file
      • From: Pascal Robert <email@hidden>
    • Re: Reading NSData from a file
      • From: Mike Schrag <email@hidden>
References: 
 >Reading NSData from a file (From: Janine Sisk <email@hidden>)
 >Re: Reading NSData from a file (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: Reading NSData from a file
  • Next by Date: Re: Reading NSData from a file
  • Previous by thread: Re: Reading NSData from a file
  • Next by thread: Re: Reading NSData from a file
  • Index(es):
    • Date
    • Thread