The problem is in your assumption that a favicon for a site is always a PNG image, which isn't the case. Normally sites use a ICO image format, which is a different image format than PNG or BMP. Read more here.
To confirm this, try downloading the Daniweb favicon and setting it up in Qt Jambi, it should work (assuming Jambi supports BMP). The same shouldn't work with Yahoo, Microsoft or any other sites' favicon.
~s.o.s~
Failure as a human
12,220 posts since Jun 2006
Reputation Points: 3,307
Solved Threads: 783
Skill Endorsements: 54
The extension suggests that it also is an ico image
Codecs don't work based on extensions, I can very well have a PNG with extension WTH and it would open up just fine in applications which support PNG.
Anyways, I personally don't know of any converters but you can try picking up ideas from this thread.
~s.o.s~
Failure as a human
12,220 posts since Jun 2006
Reputation Points: 3,307
Solved Threads: 783
Skill Endorsements: 54
Would you be using favicons from existing domains or favicons stored locally? If you would be using existing favicons, use the google ICO to PNG converter. http://www.google.com/s2/favicons?domain=daniweb.com
If you want to convert local files, you would have to find some online service like the one you mentioned. Unless the site exposes a programmatic public API, directly using the service might be a bit of pain in the neck along with other implications like taking prior permission of the site owner.
~s.o.s~
Failure as a human
12,220 posts since Jun 2006
Reputation Points: 3,307
Solved Threads: 783
Skill Endorsements: 54
I don't think there is any need for a documentation nor one exists I guess. You simply need to dynamically create a URL based on your requirement with a URL template like "http://www.google.com/s2/favicons?domain=" + yourDomain and read by the connection opened. Anyways, since I've a bit of free time, I've written a throw-away code which works; feel free to modify it as you see fit.
package pkg;
public class IcoConverterTest {
public static void main(final String[] args) {
if(args == null || args.length < 2) {
System.out.println("pkg.IcoConverterTest <domain> <outdir> <optional-file-name>");
return;
}
final String domain = args[0].trim();
final String outdir = args[1].trim();
final String fileName = args.length > 2 ? args[2].trim() : "favicon.png";
new IcoConverter().convertFor(domain, outdir, fileName);
}
}
class IcoConverter {
public static final String CONVERTER_SERVICE = "http://www.google.com/s2/favicons?domain={0}";
public void convertFor(final String domain, final String outdir, final String filename) {
InputStream is = null;
OutputStream os = null;
try {
try {
final byte[] buf = new byte[4 * 1024]; // 4kB
is = new URL(MessageFormat.format(CONVERTER_SERVICE, domain)).openStream();
os = new FileOutputStream(new File(new File(outdir), filename));
int size = -1;
while((size = is.read(buf)) != -1) {
os.write(buf, 0, size);
}
} finally {
if(is != null) is.close();
if(os != null) os.close();
}
} catch(Exception e) {
throw new RuntimeException("ICO to PNG conversion failed!", e);
}
}
}
There are a couple of gotachs when using this service, you can read about them in this discussion.
~s.o.s~
Failure as a human
12,220 posts since Jun 2006
Reputation Points: 3,307
Solved Threads: 783
Skill Endorsements: 54
I actually meant if there were any more such services that google offers (like ICO to other formats apart from PNG). I mean this is some kind of service that's not well publicized (doesn't show up on google). Where should one look for such services of google ?
Unfortunately I don't have an answer for that; I guess it's one of those "oooh, cool stuff" things.
~s.o.s~
Failure as a human
12,220 posts since Jun 2006
Reputation Points: 3,307
Solved Threads: 783
Skill Endorsements: 54
Question Answered as of 2 Years Ago by
~s.o.s~