Giter VIP home page Giter VIP logo

image-resolver's Introduction

image-resolver Build Status codecov.io 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 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.

<dependencies>
    <dependency>
        <groupId>com.shekhargulati</groupId>
        <artifactId>image-resolver</artifactId>
        <version>0.1.0</version>
    </dependency>
</dependencies>

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.

String url = "https://medium.com/the-mission/how-to-get-people-to-like-you-in-5-seconds-or-less-67e64cb91155#.tp52bdm6m";
Optional<String> mainImage = MainImageResolver.resolveMainImage(url);
// Return  Optional("https://cdn-images-1.medium.com/max/1200/1*-yql2CobEo8rGLCZv2gOyw.jpeg")

Extracting image from HTML

Optional<String> 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.

Optional<String> mainImage = MainImageResolver.resolveMainImage(url, url -> fetchHtml(), ImageResolvers.webpageResolvers);

Inspiration

This library is inspired by Maurice Svay ImageResolver JavaScript library.

image-resolver's People

Contributors

shekhargulati avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.