GithubHelp home page GithubHelp logo

n2imagehelpergithub's Introduction

ImageHelper base on Github

Tutorial

一套 library 可以讓你無 server 配合 Github 做出一套 Image Service ,因為這是 library 版本 ,如果你是想要直接使用 Server 版本,你可以到這裡 https://github.com/donma/N2ImageAgent.AzureBlob2020 ,使用 Azure 版本,除非我找時間來寫 sever 版本

Happy Coding :)

Document

Init Github ContainerInfo

            //your_github_token get from : https://github.com/settings/tokens
            var containerInfo = new N2ImageAgentGithub.ContainerInfo("your_github_token", "your_username", "yout_reponame");

            var agent = new N2ImageAgentGithub.Agent(containerInfo);

Upload Image From Local File.

           Console.WriteLine("Upload Image To Source");
           agent.UpoloadImageToSource("test1", AppDomain.CurrentDomain.BaseDirectory + "sample1.jpg", "test upload image source");
     

Upload Image From File Byte[]

            Console.WriteLine("Upload Image To Source from byte[]");
            agent.UpoloadImageToSource("test1", File.ReadAllBytes(AppDomain.CurrentDomain.BaseDirectory + "sample1.jpg"), "測試上傳:"+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

Get Image Info By Utility and Upload Info

           Console.WriteLine("Get Image Info And Upload");
           var info = Utility.GetImageInfo(AppDomain.CurrentDomain.BaseDirectory + "sample1.jpg", "imageid", "taginfo");
           Console.WriteLine(JsonConvert.SerializeObject(info));
           agent.UpoloadImageInfo(info, "測試上傳:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

Delete Image Info And Source By Id

            Console.WriteLine("Delete Source and Info");
            agent.DeleteSource("imageid");
            agent.DeleteImageInfo("imageid");

Delete All Thumb By Id

            Console.WriteLine("Delete All Thumb");
            agent.DeleteAllImageById("imageid",1000);

Is Image Source Exist

            Console.WriteLine("Check image in Source");
            agent.IsSourceExisted("imageid");

Is Image Info Exist

  
            Console.WriteLine("Check image info is existed");
            agent.IsImageInfoExisted("imageid");

Is Image Thumb Exist

           Console.WriteLine("Check image info is existed");
           agent.IsImageThumbExisted("imageid");

Get Image source or thumb url from Github

            //source 
            var source_url = agent.GetImageThumbFromSource("imageid", 0, 0);
            Console.WriteLine(source_url);
            //thumb1 : get width 100 and height depend on width.
            var thumb1 = agent.GetImageThumbFromSource("imageid", 100, 0);
            Console.WriteLine(thumb1);
            //thumb2 : get height 200 and width depend on height.
            var thumb2 = agent.GetImageThumbFromSource("imageid", 0, 200);
            Console.WriteLine(thumb2);
            

n2imagehelpergithub's People

Contributors

donma avatar

Watchers

James Cloos 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.