示例#1
0
        public TinifyImage(string tinifyApiKey, byte[] sourceImageBytes, int repeatCompressionNo)
        {
            ApiKeys = new List <TinifyApiKeyPair>
            {
                TinifyApiKeyPair.Create(tinifyApiKey, CompressRemainCountAsync(tinifyApiKey).Result)
            };

            SourceImageBytes        = sourceImageBytes;
            RepeatCompressionNumber = repeatCompressionNo;
        }
示例#2
0
        public static async Task <List <TinifyApiKeyPair> > GenerateTinifyApiKeysLocalAsync()
        {
            var lst  = new List <TinifyApiKeyPair>();
            var tiny = Connections.TinyPng.SqlConn.Query <TinyPngKey>("SELECT * FROM TinyPngKeys");

            foreach (var prop in tiny)
            {
                var tinifyKey = prop.ApiKey;
                var count     = prop.CompressRemain;
                if (count < TinifyImage.MaxCompressCount)
                {
                    lst.Add(TinifyApiKeyPair.Create(tinifyKey, count));
                }
            }
            return(lst);
        }