Пример #1
0
        protected virtual void ProcessRequest(RequestItem request)
        {
            Pixbuf orig_image;

            try {
                using (var img = imageFileFactory.Create(request.Uri)) {
                    if (request.Width > 0)
                    {
                        orig_image = img.Load(request.Width, request.Height);
                    }
                    else
                    {
                        orig_image = img.Load();
                    }
                }
            } catch (GLib.GException e) {
                Log.Exception(e);
                return;
            }

            if (orig_image == null)
            {
                return;
            }

            request.Result = orig_image;
        }
Пример #2
0
 public bool TryCreateThumbnail(SafeUri thumbnailUri, ThumbnailSize size)
 {
     try {
         var imageFile = factory.Create(fileUri);
         return(CreateThumbnail(thumbnailUri, size, imageFile));
     }
     catch {
         return(false);
     }
 }
Пример #3
0
        //FIXME: won't work on non file uris
        public uint SaveVersion(IImage buffer, bool createVersion)
        {
            if (buffer == null)
            {
                throw new ApplicationException("invalid (null) image");
            }

            uint version = DefaultVersionId;

            using (var img = imageFileFactory.Create(DefaultVersion.Uri))
            {
                // Always create a version if the source is not a jpeg for now.
                createVersion = createVersion || imageFileFactory.IsJpeg(DefaultVersion.Uri.GetExtension());

                if (createVersion)
                {
                    version = CreateDefaultModifiedVersion(DefaultVersionId, false);
                }

                try
                {
                    var versionUri = VersionUri(version);

                    ImageSharpUtils.CreateDerivedVersion(DefaultVersion.Uri, versionUri, 95, buffer);
                    GetVersion(version).ImportMD5 = HashUtils.GenerateMD5(VersionUri(version));
                    DefaultVersionId = version;
                }
                catch (Exception e)
                {
                    Log.Exception(e);
                    if (createVersion)
                    {
                        DeleteVersion(version);
                    }

                    throw e;
                }
            }

            return(version);
        }