Hướng dẫn rotate base64 image php

I am just trying to rotate the image coming from the DB, which is base 64 format. and update back the rotated image into mysql.

My Image

$imageData=mysql_real_escape_string[$rs[0]['image_data']];// base 64 format
$degrees = 180;

rotate image function

    ob_start[];
    $destImage = imagerotate[$imageData, $degrees, 0] ;     
    imageJPEG[$destImage];
    $image_thumb =mysql_real_escape_string[ob_get_contents[]];
    ob_end_clean[];

The control is not going inside ob_start[]. Please help

asked Sep 12, 2014 at 5:07

You don't want to escape the data you read from the DB, you only escape it when you write it. The raw data isn't an image resource:

$imageData = $rs[0]['image_data'];
$im = imagecreatefromstring[$data];

$degrees = 180;

ob_start[];
$destImage = imagerotate[$im, $degrees, 0] ;     
imageJPEG[$destImage];
$image_thumb =mysql_real_escape_string[ob_get_contents[]];
ob_end_clean[];

The other thing you might need to add is decode/encode for base64. Easier to store as a blob that way. otherwise you are escaping a binary string which could be a problem.

answered Sep 12, 2014 at 6:20

Garr GodfreyGarr Godfrey

7,6572 gold badges22 silver badges20 bronze badges

4

Hướng dẫn resize image python

Asked 13 years, 11 months agoViewed 1.0m times Is there an obvious way to do this that Im missing? Im just trying to make thumbnails. Ali Afshar40.1k12 gold badges90 silver badges109 bronze badges ...

Hướng dẫn rotate string python

View DiscussionImprove ArticleSave ArticleReadDiscussView DiscussionImprove ArticleSave ArticleGiven a string of size n, write functions to perform following operations on string.Left [Or ...

Check if file is image or video python

You may list media files as follows, lsmedia.py:import os def lsmedia[mypath]: img_fm = [.tif, .tiff, .jpg, .jpeg, .gif, .png, .eps, .raw, .cr2, .nef, .orf, ...

Hướng dẫn flip image python numpy

Pythons OpenCV handles images as NumPy array ndarray. There are functions for rotating or flipping images [= ndarray] in OpenCV and NumPy, either of which can be used.This article describes the ...

How to reduce image size in php

If you are looking to reduce the size using coding itself, you can follow this code in php.

Chủ Đề