Photo resizer using Java - java

I'm planning to make a simple Photo Resizer since I usually find myself having to resize huge images being sent to me. I know that there are a lot of online services and tools out there that already do this but I was thinking that it would be a good time to improve my Java and build something useful at the same time.
The problem is that I don't know where to start. I've looked around and mostly saw similar projects made in C# and C++.
Any tips on how to start this?

I did this some years ago to generate thumbnails. IIRC, you can use the ImageIO classes to read the image in as one format, and then write it back out as a different format/resolution.
edit: Oh, and here's Sun's tutorial on working with images. http://java.sun.com/docs/books/tutorial/2d/images/index.html

Related

How to use SQLite with libgdx

I was wondering if anyone knows a good tutorial that explains how to use SQLite with libgdx. All the ones I have found don't explain it well and I'm having trouble figuring out how to use it. So if you know of one that explains everything decently please give me the link to it. Thanks in advance.
Notice that the extensions available won't work for multi-platform, at max you'll be able to support Android and Desktop. My advise is for you to create your own classes for methods for accessing info stored as files on the device trough the LibGDX File API. You won't get to use SQL and it will certainly take longer but you'll get try multi-platform support (if that is what you're looking too of course).
https://code.google.com/p/libgdx-users/wiki/SQLite
Try this, although it is rather a suggestion of implementation rather than a full blown tutorial.
A Libgdx user proposed an SQLite extension several months ago. Its definitely a work-in-progress, but might be a good place to get some ideas or borrow some code from: https://github.com/libgdx/libgdx/pull/222

What library to use for a java based media player?

I'm working on developing a media player like application in Java (it's a swing based application) and I want it to be able to run on smoothly using as many different file formats as possible. I want to be able to take in a bunch of music files, then retrieve their tag information (artist/album/songname/etc), and then later play them. I've done a bit of poking around but it's hard to find a library which will support .m4a, .mp3. and maybe even .flac files. Does anyone know of a library which will do what I want? Thanks!
JMF is, to put it in the nicest possible way, rather out of date, unmaintained, difficult to distribute and in my experience has quite a few annoying bugs that crop up where you least expect them. And if you can get FMJ to work at all, good luck - they pride on it being an up to date, drop in replacement but my experience begs to differ on both those points.
Personally I wouldn't even consider it - just use separate libraries for each format or bunch of formats you want to support. JLayer would be a good one to start with as it can do a fair few, JFlac will do your flac files on top of that.
There's JMF - see http://en.wikipedia.org/wiki/Java_Media_Framework, which also lists some alternatives. I've had rather mixed success with JMF; it worked well for some static MPEG files but didn't seem compatible with the streaming sources we were using at the time (a couple of years ago).
An alternative to jFLAC for FLAC files is to use the official libFLAC, invoked via the Java native interface. See this blog post, under the headline “FLAC decoding with Java native interface” for an explanation of how it's done, with links to working code.

Best Image Scaling Library

I have searched and found a few image scaling libraries for Java. But not sure which one to go with. I need to generate thumbnails from the image uploaded by server.
It would be great if you can tell which one's good and bad.
The list I have is:
JMagick
im4java
Thumbnailator
java-image-scaling
JAI
For my simple needs, Thumbnailator was perfect. Small lib; fluent, clean, well-documented API.
In my case, it was just "net.coobird" % "thumbnailator" % "0.4.8" dependency and:
//..
Thumbnails.of(originalFile)
.size(300, 300)
.toFile(thumbnailFile)
//..
and done. Basically it’s a friendly wrapper on top of the Java 2D APIs. Useful for specific (thumbnailin') needs; no learning curve.
Unless you really need to do some heavy-lifting with images, I'd be wary of depending on an external binary (ImageMagick and wrappers like JMagick), which would add complexity and moving parts into the setup. Especially if your stack is something like mine: Scala/Java app running on Heroku. There’s stuff like heroku-buildpack-imagemagick-cedar-14, yes, but a simple dependency bundled with the app is infinitely cleaner.
Java API to generate thumbnails is not good enough if you need high quality thumbnails.
To generate high quality thumbnails use a framework like the ones you have listed. I have tried ImgScalr (https://github.com/thebuzzmedia/imgscalr) and Thumbnailator.
With my microbenchmark tests (cannot really be used for general purpose conclusions) Thumbnailator is faster - though not by a lot, and easier - especially when generating thumbnails with transparency.
I also trying out JMagick but running into issues just compiling the code and setting it up. Also a little worried about running into issues later with a framework whose basic code is written in a language I don't understand at all - C.
You might also find useful the discussion here: How can I resize an image using Java?
In my private projects, I don't use any specific library, the functionality provided for Java gives decent results for me. If you just want to do image scaling, then a complete image processing library would be too heavyweighted.
I use the code snippets given in http://www.mkyong.com/java/how-to-resize-an-image-in-java/ which works quite well.

What are currently the best image processing libraries for Java?

I am looking for a java library that can scale, crop images without losing much quality, convert between image formats (png<->jpg), etc.
There is a similar question already, but it was asked 1,5 years ago and I am hoping maybe there are any new inventions, as everything mentioned there looks outdated (and scary).
I had good results with ImageMagick for typical work on gifs and jpgs.
Take a look at the Java Advanced Imaging library.

Using Python or Java, what would be the best way to create charts?

I've been searching and found jFreeChart, Python Google Chart and matplotlib. Searching here I also found CairoPlot. I've heard I might be able to use OpenOffice to do it too. Is the API easy to use? Or would it be simpler to stick to one of those libraries?
I have more experience with Java, but I've read most of Dive Into Python 3 and done some mockup programs in Python for simple things. I'm probably gonna have to spend more time doing it in Python, though I'm willing to do it as long as it isn't anything mindblowing. I want to automate some tests to put into a thesis, so I'm more worried about the end product.
So far I'm thinking of using matplotlib simply because it's the only one that's had any recent updates, which leads me to assume there might be more documentation due to continued support. I've used jFreeChart in the past too for some testing, and it was ok. But I was hoping to find something better, or to have more documentation/examples to use. Last time I didn't customize the graphics appearance as I wanted - say, change the background in a line plot - due to the lack of examples/documentation.
I recommend you to use matplotlib, it has high quality backends and a lot of graphical representations, you'll have the whole control over your plots and Python is a very handy and easy language to automatize tests, very practical for what you're willing to do. Matplotlib has also a large community that can help you and a lot of documentation/examples; just remember that matplotlib was not ported to Python 3.x yet, I don't know if this is important for you.
What I absolutely don't recommend is CairoPlot, it is not maintained anymore and is a toy project.
Google's Visualization API is fantastic - and much cleaner if you're working in a web environment, since you just output some text JS with your HTML, don't have to call back and render an image.
JFree also has Eastwood which is a reimplementation of Google Charts API, if you don't want to send your data to Google, or need SSL, though I don't think it's quite current, it's a good subset.

Categories