Imagemagick library with codeigniter is not working,
The same image manipulation operations are working perfect with GD2 library, but not showing any output nor any errors with Imagemagic, library. What is the problem and how do I solve it? Thanks in advance
Code to resize image:
$data['title'] ='Resize Image';
$upload['upload_path'] = './assets/images/';
$upload['allowed_types'] = 'gif|jpg|jpeg|png';
$this->load->library('upload',$upload);
$filedata1 = $this->upload->data();
if(!$this->upload->do_upload('userfile')){
show_error($this->upload->display_errors());
}
$this->load->library('image_lib');
//$config['image_library'] = 'gd2';
$config['image_library'] = 'imagemagick';
$config['library_path'] = '/usr/X11R6/bin/';
$config['source_image'] = $this->upload->data('full_path');
$config['width'] ='100';
$config['height'] = 250;
$this->image_lib->initialize($config);
if(!$this->image_lib->resize()){
show_error($this->image_lib->display_errors());
}
$filedata = $this->upload->data();
$data['img2'] = base_url().'/assets/images/'.$filedata['file_name'];
print $this->load->view('pages/result',$data,true);
The problem is solved by loading the imagemagick extension in PHP setup and replacing 'ImageMagick' by imagick.
Related
The issue is:
I was using "android.net.wifi.WifiConfiguration" for connecting to WIFI like this:
Correctly Working.
from jnius import autoclass
ssid = str("ssid_name")
print("app says-->connecting to wifi:",ssid)
String = autoclass('java.lang.String')
WifiConfigure = autoclass('android.net.wifi.WifiConfiguration')
PythonActivity = autoclass('org.kivy.android.PythonActivity')
activity = PythonActivity.mActivity
service = activity.getSystemService("wifi")
WifiManager = autoclass('android.net.wifi.WifiManager')
WifiConfig = WifiConfigure()
> # # # #
Connectname = String(ssid)
connectkey = String("Wifi Password")
WifiConfig.SSID = "\""+Connectname.toString()+"\""
WifiConfig.hiddenSSID = True
WifiConfig.preSharedKey ="\""+ connectkey.toString()+"\""
added = WifiManager.addNetwork(WifiConfig)
WifiManager.enableNetwork(added, True)`
But after API 29 that java library is deprecated, and I need to deploy on Play Store the Android App Bundle with at least API 30.
So:
On site https://developer.android.com they speaking about use "android.net.wifi.NetworkSpecifier.Builder" instead of "android.net.wifi.WifiConfiguration", is there anyone to tell me how to use integrate with jnius and autoclass?
I expect python programmers to help me solve the problem
You cannot programmatically connect to Wi-Fi after API 30.
I'm trying to encode a url as an arg value like this
url = "http://test.com?a=1&b=2"
encode_url = "http://domain?url="..ngx.escape_uri(url)
then it became
http://domain?url=http%3A//test.com%3Fa%3D1%26b%3D2
but i want to this
http://domain?url=http%3a%2f%2ftest.com%3fa%3d1%26b%3d2
and I also try ngx.encode_args(), it's the same
Does anyone know why? And how should I do?
host = "http://test.com"
uri = "?a=1&b=2"
encode_host = ngx.encode_args({[host]=true})
encode_args = ngx.escape_uri(uri)
encode_url = "http://domain?url=" .. encode_host .. encode_args
Hello,
Is there a solution to this problem?
$vowels_1 = array("1","12","11");
$vowels_2 = array("One","Twelve","Eleven");
$onlyconsonants = str_replace($vowels_1, $vowels_2, "11");
echo $onlyconsonants;
Result = OneOne
It is supposed to be = Eleven
Is there a solution?
Thanks
Simple, Just swap you $vowels
$vowels_1 = array("11","12","1");
$vowels_2 = array("Eleven","Twelve","One")
I have a number of images that are sotred as blob data in my database.
I am aware this isn't a good idea, but it's what I'm using.
I have following code in my Peer class:
public function getImagesPath()
{
$file_srcs = false;
$fp = $this->getPhoto->getBlobData();
if ($fp !== null)
{
$file = stream_get_contents($fp);
$file_srcs = '/uploads/gallery/'.$this->getId().'.jpg';
}
return $file_srcs;
}
I then call this in my template, like so:
$path = $item->getImagesPath();
if ($path)
{
echo '<img src="'.$path.'" alt="Thumbnail for '.$photo->getName().'" width="153" height="153" />';
}
Now this works well, but, I have some images that are either square in shape, or rectangular.
Giving them a size/width in the img src distorts some of them.
Is there anyway, in which I could resize/crop the images before they are displayed?
Thanks
sfThumbnailPlugin is what I've used on a number of projects and it is pretty awesome. There is an older version for Symfony 1.0 if that's what you're using. By default it uses GD, but you can have it use ImageMagick and do some pretty cool things with it.
You can probably use imagecreatefromstring and imagecopyresampled. This is code that I use, that I've changed to work with your blob. This also adds a white background if the original size width/height ratio doesn't match the destination image size.
static function CreateThumbnailFromBlob($blobData, $dstWidth = 100.0, $dstHeight = 100.0){
$oldImg = #imagecreatefromstring($olduri);
if($oldImg){
$realOldW = imagesx($oldImg);
$realOldH = imagesy($oldImg);
$destX = 0;
$destY = 0;
if($realOldH>=$realOldW && $realOldH>0){
$realY = $dstHeight;
$realX = round($realY*$realOldW/$realOldH);
$destX = round($dstWidth/2-$realX/2);
}else{
$realX = $dstWidth;
if($realOldW>0)
$realY = round($realX*$realOldH/$realOldW);
else
$realY = $dstHeight;
$destY = round($dstHeight/2-$realY/2);
}
$newImg = #imagecreatetruecolor($dstWidth, $dstHeight);
$white = imagecolorallocate($newImg, 255, 255, 255);
imagefill($newImg, 1, 1, $white);
imagecopyresampled($newImg,$oldImg,$destX,$destY,
0,0,$realX,$realY,$realOldW,$realOldH);
imagedestroy($oldImg);
return $newImg;
}
}
How are you adding images to the database?
If it is via an upload form, the best method would be to create a thumbnail of the appropriate size/dimensions using GD or another library and store it in a second blob column.
Otherwise you can specify a single dimension in the html and the picture will retain its dimensions.
I'm trying to write a small Rails app that will interface with Jira using the Jira4R gem. However, whilst I'm having no problem creating an issue, I'm having real trouble attaching a custom field to an issue.
Any ideas on how I would do this?
At the moment I'm creating the issue like:
issue = Jira4R::V2::RemoteIssue.new
issue.project = "TEST"
issue.summary = params[:issue][:summary]
issue.description = params[:issue][:description]
issue.type = 6
issue = #jira.createIssue(issue)
issue = Jira4R::V2::RemoteIssue.new
issue.project = "TEST"
issue.summary = params[:issue][:summary]
issue.description = params[:issue][:description]
issue.type = 6
c = Jira4R::V2::RemoteCustomFieldValue.new
c.customfieldId = "customfield_10000"
c.values = current_user.full_name
issue.customFieldValues = [c]
issue = #jira.createIssue(issue)