I'm converting images into different sizes using ImageMagick. The conversion works OK, but there are some files that are converted twice.
For example, i'm converting a filename rj54c124a4cb96b3.56843124.tif into jpg using the suffix small.
The conversion works OK but i'm getting two of the same, like so: rj54c124a4cb96b3.56843124_small-0.jpg and rj54c124a4cb96b3.56843124_small-1.jpg
It adds a number after the suffix! Why? Like i've said, out of 3000 files, it only does that to a couple.
EDIT:
As per Keith Thompson question, here's the script im using in PHP
$file = 'c:/website_gallery/rj54c124a4cb96b3.56843124.tif';
$output = 'c:/public_html/gallery/files/4/2/rj54c124a4cb96b3.56843124_small.jpg';
$operator = '-resize'; // in some cases i will use -thumbnail
$width = 125;
$height = 125;
$flag = '^>'; // for localhost; use \> for live host server
exec('convert' . ' ' . $file . ' ' . $operator . ' ' . $width . 'x' . $height . $flag . ' ' . $output, $debug, $return);
Related
I have C:\Temp\MyFolder\mytextfile.txt in a variable called $file
I want C:\Temp\MyFolder\ in another variable.
This is quite simple
You can use this piece of code to do it:
If you want to extract file path from the your $file variable :
$file = 'C:\Temp\MyFolder\mytextfile.txt'
$myFilePath = Split-Path $file -Parent
$myFilePath = $myFilePath+'\'
Write-Host $myFilePath
If you want to extract only file name then,
$file = 'C:\Temp\MyFolder\mytextfile.txt'
$myFileName = Split-Path $file -leaf
Write-Host $myFileName
I know this is a old question but still,
If you find this answer helpful please mark this as accepted, Thank you Happy coding :)
see Extract the filename from a path
You could have found this using:
$file.psobject.properties
or
$file | get-member -membertype properties
you can obtain your result in different forms there:
$file.PSParentPath
$file.Directory
$file.DirectoryName
or using
$file | Select-object DirectoryName
or
$file | select DirectoryName
(you can add -ExpandProperties to these before DirectoryName to have an output as base property type which is String here)
Using Upload component from HTML5 Builder Embarcadero
Upload is a submit enabled button on the form. But the documentation doesn't tell me where the actual file goes. When this function is called after the supposed successful upload all the names of the upload do come out. I can see the temp file name, file name, file size, etc in the memo box. But when I try this from HTML 5 Builder in Windows 10 or on the server the uploaded target file seems to be no where. I must be missing something.
function UploadClick($sender, $params)
{
//upload the file
$this->UploadStatus->Caption = 'BtnUploadClick ' . $this->Upload1->FileName;
$this->Memo1->AddLine('FileTmpName: ' . $this->Upload1->FileTmpName);
$this->Memo1->AddLine('FileName: ' . $this->Upload1->FileName);
$this->Memo1->AddLine('FileSize: ' . $this->Upload1->FileSize);
$this->Memo1->AddLine('FileType: ' . $this->Upload1->FileType);
$this->Memo1->AddLine('FileSubType : ' . $this->Upload1->FileSubType);
$this->Memo1->AddLine('GraphicWidth: ' . $this->Upload1->GraphicWidth);
$this->Memo1->AddLine('GraphicHeihgt: ' . $this->Upload1->GraphicHeight);
if($this->Upload1->isGIF ())
$tmp = ' is gif';
if($this->Upload1->isJPEG())
$tmp = ' is jpeg';
if($this->Upload1->isPNG())
$tmp = ' is png';
$this->Memo1->AddLine('File Ext: ' . $this->Upload1->FileExt . $tmp);
}
What is not shown in the example is you need to collect the file from the server temp directory and then place it where you want:
if(move_uploaded_file($this->Upload1->FileTmpName, $this->Upload1->FileName))
{
echo "File is valid, and was successfully uploaded.\n";
}
else
{
echo "Possible file upload attack!\n";
}
Just add to the previous code and the file is saved to the server at the script location.
I have convert the PDF to image,I try using the exec,by excute the linux command like '/usr/bin/convert -density 300x300 file.pdf[0] -resample 160 -resize 512x700! images/sample-0.jpeg 2>&1'.But i have read some articles that it slow as compare to imagick php module.so try using php with code
$uploadfile = "file.pdf";
$im = new Imagick ( $uploadfile . "[0]" );
$im->setImageFormat ( "png" );
$im->writeImage ( "p-10.png" );
As you can see that i am not setting the desity and resample,the quality of image is not good at all.In php manual also there no function that set the density,i also try with setResolution,but does not work.
Please help if any body any idea about this.
have dream day
I have to print a text file created using Crystal Report import . now i Hve to print it directly to LPT1 port for fast dotmatrix printing . I used the below code, nothing is working . Any help would be greatly apprecialtable .
1.System.Diagnostics.Process.Start("Print", #"\D:LPT1" +" "+ txtFilepath);
System.Diagnostics.Process printProcess = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo PrintStartInfo = new ystem.Diagnostics.ProcessStartInfo("Print.exe");
string STRARGS = txtFilepath + " " + "/D:LPT1";
PrintStartInfo.Arguments = STRARGS;
printProcess.StartInfo = PrintStartInfo;
printProcess.Start();
printProcess.WaitForExit();
3.System.Diagnostics.Process.Start("Print", txtFilepath);
Please help me
Regards,
Martin.
Check the below link. It will solve your problem.
How to Send Raw Data to Printer
I am using the FCKEditor wysiwyg editor, and was wondering if anyone figured out how to use the absolute path instead of relative path after you add an image in the editor?
And if so, how.
Search for this code in fckeditor\editor\filemanager\browser\default\connectors\php\basexml.php:
echo '<CurrentFolder path="' . ConvertToXmlAttribute( $currentFolder ) . '" url="' . ConvertToXmlAttribute( GetUrlFromPath( $resourceType, $currentFolder ) ) . '" />' ;
Replace it with this:
echo '<CurrentFolder path="' . ConvertToXmlAttribute( $currentFolder ) . '" url="'.'http://www.YOURDOMAINHERE.com' .ConvertToXmlAttribute( GetUrlFromPath( $resourceType, $currentFolder ) ) . '" />' ;