Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shekhargulati/image-resolver
A Java 8 library to extract main image from a URL or website link
https://github.com/shekhargulati/image-resolver
extract-images image java-8
Last synced: 3 months ago
JSON representation
A Java 8 library to extract main image from a URL or website link
- Host: GitHub
- URL: https://github.com/shekhargulati/image-resolver
- Owner: shekhargulati
- License: apache-2.0
- Created: 2017-01-17T15:39:29.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-10-19T09:29:06.000Z (over 5 years ago)
- Last Synced: 2024-04-09T22:15:02.715Z (10 months ago)
- Topics: extract-images, image, java-8
- Language: Java
- Homepage:
- Size: 201 KB
- Stars: 23
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
image-resolver [![Build Status](https://travis-ci.org/shekhargulati/image-resolver.svg?branch=master)](https://travis-ci.org/shekhargulati/image-resolver) [![codecov.io](https://codecov.io/github/shekhargulati/image-resolver/coverage.svg?branch=master)](https://codecov.io/github/shekhargulati/image-resolver?branch=master) [![License](https://img.shields.io/:license-apache-blue.svg)](./LICENSE)
------A Java 8 library to extract main image from a URL.
Getting Started
--------To use image-resolver in your application, you have to add `image-resolver` in your classpath. image-resolver is available on [Maven Central](http://search.maven.org/) so you just need to add dependency to your favorite build tool as show below.
For Apache Maven users, please add following to your pom.xml.
```xml
com.shekhargulati
image-resolver
0.1.0
```
Gradle users can add following to their build.gradle file.
```
compile(group: 'com.shekhargulati', name: 'image-resolver', version: '0.1.0')
```## Using the API
It is very easy to use the API.
### Extracting image from URL.
```java
String url = "https://medium.com/the-mission/how-to-get-people-to-like-you-in-5-seconds-or-less-67e64cb91155#.tp52bdm6m";
Optional mainImage = MainImageResolver.resolveMainImage(url);
// Return Optional("https://cdn-images-1.medium.com/max/1200/1*-yql2CobEo8rGLCZv2gOyw.jpeg")
```### Extracting image from HTML
```java
Optional mainImage = MainImageResolver.resolveMainImageFromHtml(html)
```### Extracting image using your HTML fetcher
If you want to use your own way to fetch HTML then you can use.
```java
Optional mainImage = MainImageResolver.resolveMainImage(url, url -> fetchHtml(), ImageResolvers.webpageResolvers);
```## Inspiration
This library is inspired by Maurice Svay [ImageResolver](https://github.com/mauricesvay/ImageResolver) JavaScript library.