stojg / crop Goto Github PK
View Code? Open in Web Editor NEWPHP Image crops
License: BSD 2-Clause "Simplified" License
PHP Image crops
License: BSD 2-Clause "Simplified" License
Hi,
I can make a PR fixing this, but i think is better if you do it, indentation is mixed between tabs and spaces.
Regards
Implement a working version of the face aware cropping
At some places you are using php 5.4 array syntax and because of that your library doesn't behave well on php 5.3
See array syntax at http://php.net/manual/en/language.types.array.php
You have used [ ] syntax but in php 5.3 this is not supported.
Some places where you have used this syntax is:
stojg/crop/Crop.php on line 182
stojg/crop/CropFace.php on line 91
stojg/crop/CropFace.php on line 115
I was playing around with CropEntropy and noticed it had mixed results, and very strong bias to the left side of the image.
The resulting image should not have black in it.
I decided to save the slices the script generates and discovered the script doesn't take the length of the short side of the image into account. As a result the slice sizes are incorrect.
Notice that the slices don't change position, just size.
Also, if the first bSlice has more entropy than any aSlice, it will never process any of the other slices on the b-side. This means the image will be cropped to the right side even though the middle part of the image might have more entropy.
I stopped trying to fix the script and wrote my own. My script only generates square images but will actually try to crop the area with the most total entropy in it. Feel free to use any of the code.
https://github.com/ElbertF/Shot.io/blob/master/Shot/Models/Image.php
I am trying to use the "crop" script on my website for generating thumbnails of panoramic pictures. I observe a very strange result (but maybe normal) when I use "CropEntropy". My goal is to extract a thumbnail with random size for many pictures (for building a mosaic).
My approach is:
For the third point, I use the following syntax (where $image is the 400px picture):
$cropperEntropy = new stojg\crop\CropEntropy($image);
$croppedImage = $cropperEntropy->resizeAndCrop(intval($DimCropWidth),intval($DimCropHeight));
$croppedImage->writeimage($ImageNameCrop);
Using this process, I obtain a HxW picture (height H, width W) but the function resize the original 400px-picture for obtaining a picture with a height of H. Maybe this issue is normal but in my case, I have commented the line "$this->originalImage->resizeImage($crop['width'], $crop['height'], \Imagick::FILTER_CUBIC, .5);" in the Crop.php file for avoiding this and obtaining crop picture with not the whole height of my orginal picture.
I don't know if I am very clear but maybe it can be interresting to correct this issue (if it is one) or adding the possibility of extracting one box inside of a picture (with not the whole height of the original picture).
The issue seems to come from the "getSafeResizeOffset" function that fixes the cropping height to $targetHeight in my case.
Hi,
I'd love to add your library to a project I'm working on but I don't see any mention of a license. May I suggest including it in the README and/or adding a file like this?
First face detection doesn't work with GIF, because the underlying CV library doesn't support it. See: http://opencv.jp/opencv-2svn_org/c/highgui_reading_and_writing_images_and_video.html
So bug 1 would be to convert the image from GIF if needed.
But 2 is that if you do this you get an error from the getFaceList()
function because getFaceListFromClassifier()
returns false
instead of an array - and it's not expecting that.
So aside from supporting GIF's, presumably getFaceListFromClassifier()
should check for false
and return an empty array.
hi, thanks a million for an excellent cropper!
on localhost, I've got the results I wanted however in the production on a debian squeeze box there were some hoops to jump over:
convert aslice.jpg -define histogram:unique-colors=true -format %c histogram:info:-
it seems to be connected with default colorspace being sRGB on newer IM versions,
however setting the colorspace in code didn't got me wanted results
I'm going to try to upgrade the imagemagick right now
(shame that composer's require
directive is not helpful here :(
Face detection cropping should run the detection on the resized image, not the original image.
It's far too slow otherwise.
This can be done in the getFaceListFromClassifier function - write the resized image to a temporary file, then check that for faces (and then use safeZone instead of safeZoneList in getSafeZoneList).
If you are worried about accuracy then make it an option.
I've installed AWS's version of ImageMagick(which is version ImageMagick 6.7.8-9). I cannot get the entropy crop to work correctly. However when I recompile with the ImageMagick source(this is version 6.9.1) the entropy crop works fine.
Does entropy crop not work with version 6.7.8-9?
Is it possible to crop using GD instead of Imagemagick?
Hi all,
We have co-ordinate value and an image. Now, what i need is to crop image with respect to co-ordinate value and save it to local drive. can anyone help me out.
Thanks
Why do they exist both ?
Why not adding "ext-imagick": "*" to "require" section in composer.json?
Hi. I'm the creator of oscarotero/imagecow, a simple library for basic image manipulations (resize, crop, rotate and not much more).
The library has a crop()
and resizeCrop
methods and I wanted to use this library to provide a way to use the Entropy and other methods. The best way to do it is include this library as a dependency (using composer) but all methods used for the calculations are protected so I had to copy/paste the code and do some changes here's the result. According to the license, this is allowed (Redistribution and use in source and binary forms, with or without modification, are permitted...) and, of course, your copyright is included in Imagecow.
I just wanted to let you know about this and, if this library changes to a more reusable aproach, I will change Imagecow to include it as a dependency.
Thanks
I think it should be v1.3.0, because of the auto-orient functionality added since 1.2.10. Any objections?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.