give text as a watermark on picture in codeigniter code can not run properly.
public function new()
{
$this->load->library('image_lib');
$config['sourse_image'] ='./SaveImage/fer.jpg';
$config['wm_text'] = 'SaleScrap';
$config['wm_type'] = 'text';
$config['wm_font_path'] = 'system/fonts/texb.ttf';
$config['wm_font_size'] = '16';
$config['wm_font_color'] = 'ffffff';
$config['wm_vrt_alignment'] = 'bottom';
$config['wm_hor_alignment'] = 'center';
$config['wm_padding'] = '20';
$this->image_lib->initialize($config);
if($this->image_lib->watermark())
{
echo "Success";
}
else
{
echo "Error";
}
}
code not work and can not give output when code run Log File give this Error
ERROR - 2018-08-29 11:49:54 --> You must specify a source image in your preferences.
ERROR - 2018-08-29 11:49:54 --> Your server does not support the GD function required to process this type of image.
SOLUTION 1
$config['sourse_image'] ='./SaveImage/fer.jpg';
correct spelling of source_image
SOLUTION 2.
You should try this structure:
$this->load->library('image_lib');
// Set your config up
$this->image_lib->initialize($config);
// Do your manipulation
$this->image_lib->clear();
If nothing works, the error might actually be the whole issue.
Check if you have gd installed, on linux you would do
sudo yum list installed | grep php
If not installed, install it
sudo yum install php-gd-package-name
RESTART your apache
sudo service httpd restart
Related
I am migrating my existing PHP program to Laravel. I know the upload should be $request->files->store('images'); but this doesn't compress the images beforehand.
I have found Intervention Image plugin for Laravel but I don't want to use it because I want it to be pure PHP only.
My working code from pure PHP was:
$info = getimagesize($tmpFilename);
if ($info['mime'] == 'image/jpeg') {
$image = imagecreatefromjpeg($tmpFilename);
} else if ($info['mime'] == 'image/gif') {
$image = imagecreatefromgif($tmpFilename);
} else if ($info['mime'] == 'image/png') {
$image = imagecreatefrompng($tmpFilename);
}
imagejpeg($image, $path, 60);
I know the images get saved at /storage/app/public/ so I used that path for imagejpeg as well. This is my laravel code:
$tmp_file = $inner->getPathName();
imagejpeg($tmp_file, '/storage/app/public/images/hehe.jpg', 60);
But it doesn't work. It only says
imagejpeg(/storage/app/public/images/hehe.jpg): failed to open stream: No such file or directory
Any help would be appreciated
i've got problem when i install vqmod in opencart the error say
index.php not writeable
Administrator index.php not writeable
i have no index.php file in my root opencart ,
Admin/index.php
<?php
// Version
define('VERSION', '2.3.0.2');
// Configuration
if (is_file('config.php')) {
require_once('config.php');
}
// Install
if (!defined('DIR_APPLICATION')) {
header('Location: ../install/index.php');
exit;
}
// Startup
require_once(DIR_SYSTEM . 'startup.php');
start('admin');
vqmod/install/index.php
// CHANGE THIS IF YOU EDIT YOUR ADMIN FOLDER NAME
$admin = 'admin';
// Counters
$changes = 0;
$writes = 0;
// Load class required for installation
require('ugrsr.class.php');
// Get directory two above installation directory
$opencart_path = realpath(dirname(__FILE__) . '/../../') . '/';
// Verify path is correct
if(!$opencart_path) die('COULD NOT DETERMINE CORRECT FILE PATH');
$write_errors = array();
if(!is_writeable($opencart_path . 'index.php')) {
$write_errors[] = 'index.php not writeable';
}
if(!is_writeable($opencart_path . $admin . '/index.php')) {
$write_errors[] = 'Administrator index.php not writeable';
}
if(!empty($write_errors)) {
die(implode('<br />', $write_errors));
}
// Create new UGRSR class
$u = new UGRSR($opencart_path);
// remove the # before this to enable debugging info
#$u->debug = true;
// Set file searching to off
$u->file_search = false;
// Attempt upgrade if necessary. Otherwise just continue with normal install
$u->addFile('index.php');
$u->addFile($admin . '/index.php');
$u->addPattern('~\$vqmod->~', 'VQMod::');
$u->addPattern('~\$vqmod = new VQMod\(\);~', 'VQMod::bootup();');
$result = $u->run();
if($result['writes'] > 0) {
if(file_exists('../mods.cache')) {
unlink('../mods.cache');
}
die('UPGRADE COMPLETE');
}
$u->clearPatterns();
$u->resetFileList();
// Add catalog index files to files to include
$u->addFile('index.php');
// Pattern to add vqmod include
$u->addPattern('~// Startup~', '// VirtualQMOD
require_once(\'./vqmod/vqmod.php\');
VQMod::bootup();
// VQMODDED Startup');
$result = $u->run();
$writes += $result['writes'];
$changes += $result['changes'];
$u->clearPatterns();
$u->resetFileList();
// Add Admin index file
$u->addFile($admin . '/index.php');
// Pattern to add vqmod include
$u->addPattern('~// Startup~', '//VirtualQMOD
require_once(\'../vqmod/vqmod.php\');
VQMod::bootup();
// VQMODDED Startup');
$result = $u->run();
$writes += $result['writes'];
$changes += $result['changes'];
$u->addFile('index.php');
// Pattern to run required files through vqmod
$u->addPattern('/require_once\(DIR_SYSTEM \. \'([^\']+)\'\);/', 'require_once(VQMod::modCheck(DIR_SYSTEM . \'$1\'));');
// Get number of changes during run
$result = $u->run();
$writes += $result['writes'];
$changes += $result['changes'];
// output result to user
if(!$changes) die('VQMOD ALREADY INSTALLED!');
if($writes != 4) die('ONE OR MORE FILES COULD NOT BE WRITTEN');
die('VQMOD HAS BEEN INSTALLED ON YOUR SYSTEM!');
you need to do two things
1)open vqmod/install/index.php
find the following code
$admin = 'admin';
change its value to your admin folder name that you have changed to
$admin = 'youradminfoldername';
2)open vqmod/pathReplaces.php
find the following code (if there is no,add it)
$replaces[] = array('~^admin\b~', 'xxxxx');
change xxxxx to your current admin folder name.
after you have these two things,even if it still show such infomation,
you should be ok to install extension.
I have tested this method ,it works for me.
another solution I guess maybe is to delete vqmod folder and reupload vqmod-opencart-2.6.1,and then only need to modify vqmod/pathReplaces.php,it should works
It probably means that you've deleted the file. You might have to reinstall the Opencart or upload the file from default opencart source files.
Open cPanel File Manager Set permission to 777 for the file
my project ran well in localhost using xampp but in remote server I've got an error when Im trying to upload or update an image,..
warning:
Message: move_uploaded_file(images/1458100947_2.jpg):
failed to open stream: Permission denied
here is the code were the errors located.
$imagename = $this->person->view($this->input->post('id'))->image;
if(file_exists("images/$imagename")) unlink("images/".$imagename);
$fileName = time(). '_' .$_FILES["image"]["name"];
move_uploaded_file($_FILES["image"]["tmp_name"],$output_dir.$fileName); //this line
$targetPath = 'images/' . $fileName;
$config_resize['image_library'] = 'gd2';
$config_resize['create_thumb'] = FALSE;
$config_resize['maintain_ratio'] = TRUE;
// $config_resize['master_dim'] = 'height';
$config_resize['quality'] = "80%";
$config_resize['source_image'] = $targetPath;
$config_resize['height'] = 600;
$config_resize['width'] = 1024;
// $config_resize['thumb_marker'] = '';
$config_resize['new_image'] = 'images/' . $fileName;
$this->image_lib->initialize($config_resize);
$this->image_lib->resize();
$uploaded = TRUE;
I am trying to google on how to set the permission to 777 in codeigniter but no luck.. here is my project link http://mysports.orgfree.com. use this admin account.
username: mak password: mak
to login and click the edit button then upload some image.. the error will show after that.. thank you...
Hello you can give 2 way permission
1) directly give folder permission using this way
chmod("folder name with path", 755);
2)directly give file permission using this way and use this code after move_uploaded_file function
chmod("file name with path", 644);
I was able to fix my permission issue by using SmartFTP to upload the files, because it provides an easy way to set the permission. This resolved my question and my code works now.
I'm using intervention/image module with laravel 4.2 , to upload images i'm using this code :
if (Input::hasFile('image'))
{
$file = Input::file('image');
$file->move('uploads/2/', $file->getClientOriginalName());
$image = Image::make(sprintf('uploads/2/%s', $file->getClientOriginalName()))->resize(120, 120)->save();
return 'yes';
}
With some images it works , with some images it produces this error :
imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file
switch ($info[2]) {
case IMAGETYPE_PNG:
$core = imagecreatefrompng($path);
$this->gdResourceToTruecolor($core);
break;
case IMAGETYPE_JPEG:
$core = imagecreatefromjpeg($path);
$this->gdResourceToTruecolor($core);
break;
This is because you upload corrupted images and GD can't handle that kind of images. Please check it in this issue .
Try to suppress this error like this.
ini_set('gd.jpeg_ignore_warning', true);
Hope it will be useful for you.
I have an application that works on my local, development server, but when uploaded to the remote, production server I see the following error:
Fatal error: require_once() [function.require]: Failed opening required '/home/madhab/public_html/system/database/drivers/mysql/mysql_driver.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/madhab/public_html/system/database/DB.php on line 140
What's the matter? How can I resolve it?
//my database configuration as
$active_group = 'server';
$active_record = TRUE;
$db['server']['hostname'] = 'madhab-acharya.com.np';
$db['server']['username'] = '***********';
$db['server']['password'] = '***********';
$db['server']['database'] = '***********';
$db['server']['dbdriver'] = 'mysql';
$db['server']['dbprefix'] = '';
$db['server']['pconnect'] = TRUE;
$db['server']['db_debug'] = TRUE;
$db['server']['cache_on'] = FALSE;
$db['server']['cachedir'] = '';
$db['server']['char_set'] = 'utf8';
$db['server']['dbcollat'] = 'utf8_general_ci';
$db['server']['swap_pre'] = '';
$db['server']['autoinit'] = TRUE;
$db['server']['stricton'] = FALSE;
//and my index.php file setting is
$system_path = 'system';
$application_folder = 'application';
$assets_folder = 'assets';
while my application, system, index.php resides on public_html folder in remote server
somebody please help me thro this
Problem is with mysql host.
normally it is like madhab-acharya.mysqlserver.com.np. I think you have give your web site name.
Please check your sql hostiname with your web service provide or you can find it in phpadmin panel.
If this is correct ensure that every file is uploaded correctly. Sometimes I had to do second time when I put site in productions.