Cannot rotate images

See all posts Reply

Cannot rotate images new!
by Keith Taylor, 8 years, 8 months ago
I'm doing this:

include('classes/class.upload.php');
$thePic = $pics->getOneRow($_GET['id']);
$handle = new upload('/images/small/'.$thePic[0]['image']);
$handle->file_overwrite = true;
$handle->image_rotate = 180;
$handle->process();
unset($handle);

The first two lines are just about getting the file name and path from the database & they work OK.

Nothing apparently happens - the image is not rotated. If I leave file_overwrite as default ( NOT to overwrite) then it works, but the file is renamed like file_1.jpg. I don't want to change the file name when it is rotated.

What am I doing wrong ?
rgds
KTReply
Re: Cannot rotate images new!
by colin, 8 years, 8 months ago
Can you copy here the log produced by the class?Reply
Re: Cannot rotate images new!
by Keith Taylor, 8 years, 8 months ago
Sorry for delay - been wrestling with Windows 10 - all sorted now.

Where does the class write the log to and what is the log file's name ?? Do you have to turn logging on ?

BTW - the class uploads and resizes pictures with no problems.
KTReply
Re: Cannot rotate images new!
by colin, 8 years, 8 months ago
Use echo $handle->log; after your call to process()Reply
Re: Cannot rotate images new!
by Keith Taylor, 8 years, 8 months ago
Here it is
system information
- class version : 0.33dev
- operating system : WINNT
- PHP version : 5.6.12
- GD version : 2.1.0
- supported image types : png jpg gif bmp
- open_basedir : no restriction
- upload_max_filesize : 20M (20971520 bytes)
- language : en_GB
source is a local file /images/small/billionphotos-1896281.png
- error: File not uploaded. Can't carry on a process.Reply
Re: Cannot rotate images new!
by colin, 8 years, 8 months ago
Your file is not actually processed, according to the log. Check whether the source file exists, and your script has the permissions to access it.

Note I don't support the class on Windows; it should work, but I have no way to test it.Reply
Re: Cannot rotate images new!
by Keith Taylor, 8 years, 8 months ago
Right - I had the path to the file wrong . Now I get this:
It says "Process OK" but the file is till not rotated
///
system information
- class version : 0.33dev
- operating system : WINNT
- PHP version : 5.6.12
- GD version : 2.1.0
- supported image types : png jpg gif bmp
- open_basedir : no restriction
- upload_max_filesize : 20M (20971520 bytes)
- language : en_GB
source is a local file images/small/billionphotos-940634.png
- local file OK
determining MIME type
- Checking MIME type with Fileinfo PECL extension
MAGIC path defaults to C:\phpextras/magic
Fileinfo PECL extension failed (finfo_open)
- Checking MIME type with UNIX file() command
UNIX file() command not availabled
- Checking MIME type with mime.magic file (mime_content_type())
MIME type detected as image/png by mime_content_type()
- MIME validated as image/png
source variables
- You can use all these before calling process()
file_src_name : billionphotos-940634.png
file_src_name_body : billionphotos-940634
file_src_name_ext : png
file_src_pathname : images/small/billionphotos-940634.png
file_src_mime : image/png
file_src_size : 16715 (max= 20971520)
file_src_error : 0
- source file is an image
image_src_x : 150
image_src_y : 150
image_src_pixels : 22500
image_src_type : png
image_src_bits : 8
process file and return the content
- file size OK
- file mime OK : image/png
- file name safe format
- destination variables
file_dst_path : n/a
file_dst_name_body : billionphotos-940634
file_dst_name_ext : png
- image resizing or conversion wanted
- source image is PNG
- setting destination file type to png
- rotate image : 180
- converting...
- saving image...
PNG image created
image objects destroyed
- process OKReply
Re: Cannot rotate images new!
by colin, 8 years, 8 months ago
Does it work if you resize by 90 degrees for instance?Reply
Re: Cannot rotate images new!
by Keith Taylor, 8 years, 8 months ago
I tried 90 and 270 degrees - still no rotate.

As for the permissions on the file - I'm not sure who the owner of the file is or the name of the user who is trying to change it. I assumed that because the class had uploaded and written the file ( after resizing ) there would be no subsequent problems with permissions.

I note on the log that it says: file_dst_path : n/a . Is that relevant ?Reply
Re: Cannot rotate images new!
by colin, 8 years, 8 months ago
Can you try the test procedure in the test/ directory? Runthe test in the section "Image local manipulation".

In the tests, there are some rotations. Are they working?Reply
Re: Cannot rotate images new!
by Keith Taylor, 8 years, 8 months ago
Hi Colin

Yes - ALL the tests on that test page are working OK on this machine. Strange !

I looked at your script and noticed that degrees are quoted i.e.
$handle-0>image_rotate='180';
so I did the same in my script, but it made no difference.

Time for some serious head scratchingReply
Re: Cannot rotate images new!
by colin, 8 years, 8 months ago
Yes, I am not sure what is going on... You can try to debug the class, ar do some more tests of your code, with different image formats, sizes, types, etc...Reply
Re: Cannot rotate images new!
by Keith Taylor, 8 years, 8 months ago
It is strange - but there must be a logical explanation. I will play around and see what I can do. I'll post here when I find the solution

Many thanks for your time
KTReply
Re: Cannot rotate images new!
by Keith Taylor, 8 years, 8 months ago
In your demo you don't actually write the modified file back to the disk - you just show it. Do I need to use another method to actually save the file after processing ?Reply
Re: Cannot rotate images new!
by Keith Taylor, 8 years, 8 months ago
Got it !
$handle->image_rotate = '90';
$handle->file_overwrite = true;
$handle->process('images/small');

You have to quote the file path in the process method. Not intuitive, as the class already knows the full path from when it is instantiated.Reply
Re: Cannot rotate images new!
by colin, 8 years, 8 months ago
I should have caught that in your code... Indeed, you need the path when calling process(), as an absolute or relative path.

If you call process() without an argument, it outputs the image directy to the browser. It is documented hereReply