Square thumbnails - typo3

I want to generate a square thumbnail from a sourceimage for a TYPO3 gallery extension, but I don't find a way to do this. It can be a square section from the source image.
To decrease the image proportional to an thumbnail, i use the following function:
function generateImg($w,$h,$fname,$dir,$class,$id){
$imgTSConfig = array();
$imgTSConfig['file'] = $dir.'/'.$fname;
$imgTSConfig['file.']['maxW'] = $w;
$imgTSConfig['file.']['maxH'] = $h;
$imgTSConfig['stdWrap.']['addParams.']['class'] = $cl;
$imgTSConfig['stdWrap.']['addParams.']['id'] = $id;
$timg = $this->cObj->image($imgTSConfig);
return($timg);
}

Try this:
$imgTSConfig['file.']['width'] = '120';
$imgTSConfig['file.']['height'] = '120c';
...instead of (or combined with) maxH and maxW. The 'c' parameter crops the image if it is to high.
Source

Related

html2canvas toDataURL(image/png") return poor image quality

I tried to use html2canvas to get image screenshot byte from website. However, the screenshot result ended with poor resolution. Looking for advice to improve screenshot quality. Thanks.
How about something like this:
var $wrapper = $("#yourDiv");
setSize($wrapper, "2000px", "20pt");
html2canvas($wrapper, {
onrendered: function (canvas) {
var a = document.createElement('a');
a.href = canvas.toDataURL("image/jpg");
a.download = 'filename.jpg';
a.click();
setSize($wrapper, "1000px", "10pt");
}
});
function setSize(dv, width, fontsize) {
dv[0].style.width = width;
dv[0].style.fontSize = fontsize;
}
This resizes the div and font to bigger size and then shrinks back afterwards.

zxing Datamatrix generator creating rectangular barcode which can't be scanned

I am using barcodewriter to write datamatrix barcoe. While most of the times it creates correct square style datamatrix barcode, for some of text it creates rectangular shaped barcode.
For inputData like below it creates rectangular barcode
8004600000070000017
C/TH PAUL PENGELLY
C/TH NICKY PARSONS
C/TH ROSEMARIE BARTOLOME
while for others it creates square styled: CTH HEKT-WOODROW MORGAN
800460000007
800460000007000001700000
i am usinf this code to generate code:
BarcodeWriter writer = new BarcodeWriter() { Format = BarcodeFormat.DATA_MATRIX };
var img = writer.Write(inputData);
return new Bitmap(img);
img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
dto.BarcodeImage = ms.ToArray();
How can I make sure that I always get Square shaped datamatrix?
I have alread tried adding height,width options.
Thanks
There is SymbolShape option which can be used to force shape .
DatamatrixEncodingOptions options = new DatamatrixEncodingOptions()
{
Height = 300,
Width = 300,
PureBarcode = true,
Margin = 1,
SymbolShape = SymbolShapeHint.FORCE_SQUARE
};
It is not easy to detect but after careful reviewing, I found how to do it.
readonly DataMatrixWriter DMencoder = new();
readonly Dictionary<EncodeHintType, object> DMencodeType = new()
{
[EncodeHintType.DATA_MATRIX_DEFAULT_ENCODATION] = Encodation.C40, //Optional
[EncodeHintType.DATA_MATRIX_SHAPE] = SymbolShapeHint.FORCE_SQUARE
};
DMencoder.encode(matrixText, BarcodeFormat.DATA_MATRIX, 100, 100, DMencodeType)

TYPO3 modyfing img source on tt_news list item

I'm trying to add additional parameter to tt_news img list source: data-src="path-to-img". Is it possible? I try with generic marker but without any success:
plugin.tt_news.genericmarkers {
data = imgsource
imgsource = TEXT
imgsource {
field = image
wrap = <img src="uploads/pics/|" data-src="uploads/pics/|" />
file.maxW = 112
file.maxH = 124
}
}
But on output I only have this in source: <img src="uploads/pics/img.jpg" data-src="uploads/pics/ without second img source, img size and close tag.
Any suggestions?
Some remarks before I show you an example:
the »wrap« property only allows one pipe (TYPO3 is replacing the first »|« character with the current value), that why your second parameter is empty
the TEXT objekt only allows value and all properties listed in the »stdWrap« section (see TEXT object: http://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Text/Index.html, list of all stdWrap-properties http://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Stdwrap/Index.html)
so TEXT does have properties like »wrap« or »case« or »substring«, but no »file«
what you want is an IMAGE object, which allows to manipulate images
plugin.tt_news.genericmarkers {
imgsource = IMAGE
imgsource {
file.import = uploads/pics/
file.import.field = image
file.import.listNum = 0
file.width = 250
# if you just want to link the original image
params.field = image
params.wrap = data-src="/uploads/pics/|"
/*
# if you want want to manipulate the image as well, then use this code instead
# IMG_RESOURCE is almost the same as IMAGE, but returns only the path to the resulting image, not the »<img src="">«-Markup
params.cObject = IMG_RESOURCE
params.cObject {
file.import = uploads/pics/
file.import.field = image
file.import.listNum = 0
file.width = 500
stdWrap.wrap = data-src="|"
}
*/
}
}

How to get proper image in pdf doc with its height and width using zend_pdf class

I am facing a problem with zend_pdf as I am not getting the quality of the image and actual height and width of the image in zend pdf documents.
below is the function which I am using
$pdf = new Zend_Pdf();
$page = $pdf->newPage('510:745:');
$pdf->pages[] = $page;
$image = Zend_Pdf_Image::imageWithPath($imagePath);
$page->drawImage($image, 100,100,400, 300);
So how can I get the quality of an image with its proper height and width with Zend_pdf?
Thanks
Change the size as original. It would be help to maintain the original quality of the picture.
Maybe getPixelWidth() and getPixelHeight() works better. Like this:
$img = Zend_Pdf_Image::imageWithPath('myimage.png');
$page->drawImage($img, 0, 0, $img->getPixelWidth(), $img->getPixelHeight());

How to disable Fusioncharts legend area?

How can I disable/remove the legend area when using FusionCharts? I'll be using a very small chart, so the legend area is not necessary.
Adding a showLegend='0' tag should disable it. Use it like this:
<chart showLegend='0'...>
Check out FusionCharts Legend API for more help on legends.
How to set Show legend property to my Fusion Graph.My code like this.
public Pie2DChart GetServiceEsclationChart(DataTable BarChartdt, string CaseType)
{
Pie2DChart oChart3 = new Pie2DChart();
// Set properties
oChart3.Background.BgColor = "ffffff";
oChart3.Background.BgAlpha = 50;
oChart3.ChartTitles.Caption = "Case Type Count";
oChart3.ChartTitles.Caption = CaseType;
// oChart.ChartTitles.SubCaption = "2013-2014 Year";
// Set a template
oChart3.Template = new Libero.FusionCharts.Template.OfficeTemplate();
// Set data
oChart3.DataSource = BarChartdt;
oChart3.DataTextField = "Name";
oChart3.DataValueField = "Value";
//Load it into ViewData.
// ViewData["SREsclation"] = oChart3;
return oChart3;
}