Excel catalyst 35th wave of open source - such as picture compression and automatic rotation process

Excel catalysts image processing, but also to the extreme of the general Excel original picture is inserted into card insertion or uncontrolled compression ratio to be inserted image among Excel, Excel catalyst but insert a picture, a picture size can be adjusted to develop a the insert mode, so that images can be expected to balance file size and pixel size in Excel.
In the picture processing, it can help a great library, to achieve Mito Xiu Xiu is so routine image processing.

Excel catalyst function Cipian corresponding implementation: 11 wave - fast batch insert a picture and protect the aspect ratio unchanged https://www.jianshu.com/p/9a3d9aa7ba7e

Excel catalyst picture approach, uses a library: ImageFactory, which has a very rich image processing functions, is that of a python picture library.

Specific detailed usage can refer to the official website: https://imageprocessor.org/imageprocessor/imagefactory/#example

It has more than desktop version, there are web version, processing performance soon, no memory leaks.
google translate official website

Code calls very elegant simplicity, taken from the official website of the sample code is as follows:

byte[] photoBytes = File.ReadAllBytes(file);
// Format is automatically detected though can be changed.
ISupportedImageFormat format = new JpegFormat { Quality = 70 };
Size size = new Size(150, 0)
using (MemoryStream inStream = new MemoryStream(photoBytes))
{
    using (MemoryStream outStream = new MemoryStream())
    {
        // Initialize the ImageFactory using the overload to preserve EXIF metadata.
        using (ImageFactory imageFactory = new ImageFactory(preserveExifData:true))
        {
            // Load, resize, set the format and quality and save an image.
            imageFactory.Load(inStream)
                        .Resize(size)
                        .Format(format)
                        .Save(outStream);
        }
        // Do something with the stream.
    }
}

Excel snippet catalyst used is as follows:

The longest side of the image is controlled using the method according to the Exif information AutoRotate rotate the image, and then use the resize Resize method, the final image is too big fear, the compression method by Quality.

Because the upper method requires the use Image objects can not be released in the current method, its return Clone, do not know whether this treatment is reasonable, there is expert advice can see the next.

        public static Image GetImageByReduceSize(string filePath)
        {
            using (ImageFactory imageFactory = new ImageFactory())
            {
                var img = imageFactory.Load(filePath);
                img.AutoRotate();
                int picInsertSrcMaxPixed = Properties.Settings.Default.PicInsertSrcMaxPixed;

                Size orgSize = img.Image.Size;
                if (orgSize.Height > orgSize.Width)
                {
                    if (orgSize.Height > picInsertSrcMaxPixed)
                    {
                        img.Resize(new Size(0, picInsertSrcMaxPixed));
                    }
                }
                else
                {
                    if (orgSize.Width > picInsertSrcMaxPixed)
                    {
                        img.Resize(new Size(picInsertSrcMaxPixed, 0));
                    }
                }

               return (Image)img.Quality(70).Image.Clone();
            }
        }

Technical exchange QQ group

QQ group name: Excel catalyst open discussion groups, QQ group number: 788 145 319
Excel catalyst dimensional code open source discussion groups

About Excel catalyst

Excel催化剂先是一微信公众号的名称,后来顺其名称,正式推出了Excel插件,插件将持续性地更新,更新的周期视本人的时间而定争取一周能够上线一个大功能模块。Excel催化剂插件承诺个人用户永久性免费使用!

Excel催化剂插件使用最新的布署技术,实现一次安装,日后所有更新自动更新完成,无需重复关注更新动态,手动下载安装包重新安装,只需一次安装即可随时保持最新版本!

Excel催化剂插件下载链接:https://pan.baidu.com/s/1Iz2_NZJ8v7C9eqhNjdnP3Q

Contact the author

No public

取名催化剂,因Excel本身的强大,并非所有人能够立马享受到,大部分人还是在被Excel软件所虐的阶段,就是头脑里很清晰想达到的效果,而且高手们也已经实现出来,就是自己怎么弄都弄不出来,或者更糟的是还不知道Excel能够做什么而停留在不断地重复、机械、手工地在做着数据,耗费着无数的青春年华岁月。所以催生了是否可以作为一种媒介,让广大的Excel用户们可以瞬间点燃Excel的爆点,无需苦苦地挣扎地没日没夜的技巧学习、高级复杂函数的烧脑,最终走向了从入门到放弃的道路。

最后Excel功能强大,其实还需树立一个观点,不是所有事情都要交给Excel去完成,也不是所有事情Excel都是十分胜任的,外面的世界仍然是一个广阔的世界,Excel只是其中一枚耀眼的明星,还有其他更多同样精彩强大的技术、工具等。*Excel催化剂也将借力这些其他技术,让Excel能够发挥更强大的爆发!

关于Excel催化剂作者

Name: Li Weijian, for many years engaged in data (BI direction) analysis, a learner in the same way.
Served industries: retail category in particular shoes retail industry, electricity providers (Taobao, Lynx, Jingdong, the only product)

Technical route from an ordinary user, through the Excel software to learn, go from the data world, Coban non-IT professionals.
After many difficulties, and finally reach the plains of technical data on the road, learning many knowledge is no longer too difficult, but also formed its own set of data solutions (data collection, data cleaning and processing, multi-dimensional data modeling, data reporting display, etc.).

Specializes in technology areas: Excel and other Office family of software, the secondary development of VBA & VSTO, Sqlserver database technology, business intelligence BI technology Sqlserver of, Powerbi technology, cloud server deployment technologies.

2018 began his career made a major adjustment, from the original full-time job, turned freelance, no fixed income, temporarily on the road ahead is not clear, bitter return to full-time job, for Excel catalyst operations and development must be greatly affected (within the time could not maintain full-time job can not just put the results in a work published in time, the time outside of work is very limited, because he has thirty years of age, family responsibility).

And the majority of advocates with expectations: Excel catalyst has been able to run down, I have the benefit of the group were able to support ( multi-message encouragement, friend circle under forwarded the recommendation under small a reward and the most focused and where the company can and recommended recommended peers, so I can maximize the value of technology in your company to achieve a win-win (you can imagine how the data is preliminary consultant or small projects to develop forms of cooperation).

Guess you like

Origin www.cnblogs.com/ExcelCuiHuaJi/p/11225022.html