Forum

Thread tagged as: Problem

Image cropping not working

Hi,

I'm not quite sure what is happening here, but this is what I think should be happening.

In my template, I have a perch content tag to allow uploading of a specific image to be used as a thumbnail - see below:

<perch:content id="contentsMainImage" label="Contents Image:" type="image" width="100" height="65" crop="true" suppress="true" />

I then want to re-use this image on another template, so I just add in the the same tag without the suppress element, as such:

<img src="<perch:content id="contentsMainImage" type="image" width="100" height="65" crop="true" />" class="img-responsive border" />

Now, in practice, from the administration panel, I click on the 'Select or upload an image' link and this opens the 'Select an Asset' side bar. Now, if I select an image from within this that has a native size of say 320px x 240px, I would expect the system to crop this to the given dimensions, removing parts of the image where required, i.e. they are not the same aspect ratio.

When I press save from the admin panel and review, I can see that the image has been added and the admin panel states it is 100px x 65px and also shows the smaller filesize.

However, when I then look at the page where the image is displayed, it is showing the image in it's original aspect ratio (so in this instance greater than 65px depth) and also, it is using the 320px x 240px original, not the 'crop' version.

As you can see I have used an img-responsive class which just adds:

.img-responsive {
    display: block;
    height: auto;
    max-width: 100%;
}

and so, I will probably end up using a 'larger' image anyway, but the above goes against what I understand to be true. Especially, if I use an even larger image, say width 750px but correct aspect ratio, the thumbnail renders correctly, but I am still using the larger image.

The css cannot be effecting it, so I am wondering why the image does not seem to be 'cropping' and being saved at a different size, yet it states it has in the admin panel.

Am I getting the whole image resize thing wrong ?

For reference, I have attached my diagnostics report and yes, php is well out of date:


Perch: 2.7.2 Production mode: Production (100) Installed apps: content (2.7.2), assets (2.7.2), categories (2.7.2) DB driver: PDO DB tables: perch2_categories, perch2_category_counts, perch2_category_sets, perch2_content_index, perch2_content_items, perch2_content_regions, perch2_members, perch2_members_forms, perch2_members_member_tags, perch2_members_sessions, perch2_members_tags, perch2_navigation, perch2_navigation_pages, perch2_page_templates, perch2_pages, perch2_resource_log, perch2_resource_tags, perch2_resources, perch2_resources_to_tags, perch2_settings, perch2_user_privileges, perch2_user_role_privileges, perch2_user_roles, perch2_users Users: 1 App runtimes: <?php // CORE INSTALLATION // include(PERCH_PATH.'/core/apps/content/runtime.php'); // MEMBERS APP // //include(PERCH_PATH.'/addons/apps/perch_members/runtime.php'); ?> Editor plug-ins: markitup, redactor, _redactor H1: adbbb6bdd4d9c33efd6e5cd981aae800 L1: aa36df371099aa91db4b07e25b418ddf headerColour: #ffffff content_singlePageEdit: 1 helpURL: siteURL: / hideBranding: 1 content_collapseList: 1 lang: en-gb update_2.4.9: done latest_version: 2.5.3 on_sale_version: 2.7.2 perch_blog_post_url: /blog/post.php?s={postSlug} perch_blog_update: 4.0 headerScheme: light perch_members_login_page: /signin.php?r={returnURL} dashboard: 0 hide_pwd_reset: 0 content_hideNonEditableRegions: 0 content_frontend_edit: 0 logoPath: /perch/resources/rq-logo-trans-admin.png update_2.6.6: done update_2.7.2: done PERCH_DEVELOPMENT: 10 PERCH_STAGING: 50 PERCH_PRODUCTION: 100 PERCH_DB_USERNAME: root PERCH_DB_SERVER: localhost PERCH_DB_DATABASE: kdl_qm PERCH_DB_PREFIX: perch2_ PERCH_TZ: Europe/London PERCH_EMAIL_FROM: contact@kennedydigitalltd.com PERCH_EMAIL_FROM_NAME: Andrew Kennedy PERCH_LOGINPATH: /admin PERCH_PATH: E:\KDL_Projects_Open\kdl_mtc\www\admin PERCH_CORE: E:\KDL_Projects_Open\kdl_mtc\www\admin\core PERCH_RESFILEPATH: E:\KDL_Projects_Open\kdl_mtc\www\admin\resources PERCH_RESPATH: /admin/resources PERCH_HTML5: 1 PERCH_RUNWAY: PERCH_ERROR_MODE: DIE PERCH_DATE_LONG: %d %B %Y PERCH_DATE_SHORT: %d %b %Y PERCH_TIME_SHORT: %H:%M PERCH_TIME_LONG: %H:%M:%S PERCH_DEBUG: PERCH_PREVIEW_ARG: preview PERCH_TEMPLATE_PATH: E:\KDL_Projects_Open\kdl_mtc\www\admin\templates PERCH_DEFAULT_DOC: index.php PERCH_DEFAULT_EXT: .php PERCH_PRODUCTION_MODE: 100 PERCH_RWD: PERCH_HTML_ENTITIES: PERCH_SSL: PERCH_AUTH_PLUGIN: PERCH_DB_CHARSET: utf8 PERCH_DB_PORT: PERCH_DB_SOCKET: Hosting settings PHP: 5.3.5 Zend: 2.3.0 OS: WINNT SAPI: apache2handler Safe mode: not detected MySQL client: mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $ MySQL server: 5.5.8 Extensions: Core, bcmath, calendar, com_dotnet, ctype, date, ereg, filter, ftp, hash, iconv, json, mcrypt, SPL, odbc, pcre, Reflection, session, standard, mysqlnd, tokenizer, zip, zlib, libxml, dom, PDO, bz2, SimpleXML, wddx, xml, xmlreader, xmlwriter, apache2handler, Phar, curl, mbstring, exif, gd, gettext, imap, mysql, mysqli, pdo_mysql, PDO_ODBC, pdo_sqlite, soap, sockets, SQLite, sqlite3, xmlrpc, ming, mhash GD: Yes ImageMagick: No PHP max upload size: 256M PHP max form post size: 256M PHP memory limit: 256M Total max uploadable file size: 256M Resource folder writeable: Yes Session timeout: 24 minutes Native JSON: Yes Filter functions: Yes Transliteration functions: No MIBDIRS: E:/xampp/php/extras/mibs MYSQL_HOME: \xampp\mysql\bin OPENSSL_CONF: E:/xampp/apache/bin/openssl.cnf PHP_PEAR_SYSCONF_DIR: \xampp\php PHPRC: \xampp\php TMP: \xampp\tmp HTTP_HOST: qm.kdl HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0 HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.5 HTTP_ACCEPT_ENCODING: gzip, deflate HTTP_REFERER: https://qm.kdl/admin/core/settings/diagnostics/ HTTP_COOKIE: cmsa=1; __utma=39007267.395616086.1413899748.1415354555.1415359204.57; __utmz=39007267.1413899748.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); PHPSESSID=t87jqjd32u0mgh7k81t4ipv251; cmssb=0; yPos=!~0~!; __utmc=39007267; __utmb=39007267.35.10.1415359204; __utmt=1 HTTP_CONNECTION: keep-alive PATH: C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\TortoiseSVN\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\QuickTime\QTSystem\; SystemRoot: C:\windows COMSPEC: C:\windows\system32\cmd.exe PATHEXT: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC WINDIR: C:\windows SERVER_SIGNATURE: <address>Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1 Server at qm.kdl Port 80</address> SERVER_SOFTWARE: Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1 SERVER_NAME: qm.kdl SERVER_ADDR: 127.0.0.1 SERVER_PORT: 80 REMOTE_ADDR: 127.0.0.1 DOCUMENT_ROOT: E:/KDL_Projects_Open/kdl_mtc/www SERVER_ADMIN: postmaster@localhost SCRIPT_FILENAME: E:/KDL_Projects_Open/kdl_mtc/www/admin/core/settings/diagnostics/index.php REMOTE_PORT: 63567 GATEWAY_INTERFACE: CGI/1.1 SERVER_PROTOCOL: HTTP/1.1 REQUEST_METHOD: GET QUERY_STRING: extended REQUEST_URI: /admin/core/settings/diagnostics/?extended SCRIPT_NAME: /admin/core/settings/diagnostics/index.php PHP_SELF: /admin/core/settings/diagnostics/index.php REQUEST_TIME: 1415362947

Any help is appreciated. Maybe the assets app isn't set-up correctly or not working as I expect ??

Thanks,

Andy

Andrew Kennedy

Andrew Kennedy 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

That looks like it should work. Which page function are you using to display the template?

the page function is quite complicated, as there are a series of perch_content_custom calls, as I needed to organise my 'multiple entry item' in a specific way, i.e. some entries are from section A, B, C etc.

So, a 'typical' perch_content_custom call is:

<?php
    $industrycount = 0;
    $industry = perch_content_custom('ISSUE', array(
        'page' => '/q4-2014-contents.php',
        'template' => 'issue-listing-industrynews.html',
        'filter'=>'articleSection',
        'match' =>'eq',
        'value' => 'B',
        'sort'=>'articleSection',
        'sort-order'=>'DESC',   
        'skip-template' => true,
        'return-html' => true,
        'each' => function($item) {
                global $featurescount, $industrycount;
            $industrycount++;
            $item['pagination_index'] = $featurescount + $industrycount;
            return $item;
        },
    ));
echo $industry['html'];
?>

The reason for the count is so that I can loop through all the entries and return the 'items' given a specific value that is set via the template.

However, I would be suprised if this is somehow causing the 'crop of an image no to work ?

Also, since writing the first post, I have tried re-adding the image once more from the sidebar assets tab and I have now, for this first time, got the following error message:

Warning: filesize() [function.filesize]: stat failed for E:\myproject\www\admin\resources\q4-2014-feature2-w750h400.jpg in E:\myproject\www\admin\core\lib\PerchFieldTypes.class.php on line 1001

Warning: filesize() [function.filesize]: stat failed for E:\myproject\kdl_mtc\www\admin\resources\q4-2014-feature2-w100h65.jpg in E:\myproject\www\admin\core\lib\PerchFieldTypes.class.php on line 1001

I'm sure I've seen this on another post in my research before I posted my issue, so I will look back over things.

Any ideas ?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is this local or on a production server?

Hi Drew, it's a local instal on XAMPP

Drew McLellan

Drew McLellan 2638 points
Perch Support

Does that path look correct for your system?

E:\myproject\www\admin\resources\q4-2014-feature2-w750h400.jpg

I'm wondering if this is Windows related.

Yes that looks correct.

Well, it's actually slightly different, as I used 'myproject' to hide the name of the particular client, but yes, in essence this path is correct.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Hmm. The error seems to be that PHP can't read the file for some reason. I'm not sure why that would fail if the image is there and the permissions are correctly set.

Yeah, it's all rather odd. Ok, I can 'get around' this for the project, but I just wanted to check it wasn't me going crazy !

I think there is something funky going on with the instal, as I have now just tried to add a search element to the site and I am getting the errors:

Warning: func_get_arg(): Argument 1 not passed to function in E:\myproject\www\admin\core\apps\content\PerchContent_SearchHandler.class.php on line 26

and

Warning: func_get_arg(): Argument 1 not passed to function in E:\myproject\www\admin\core\apps\content\PerchContent_SearchHandler.class.php on line 43

I'm going to re-install the core and see if that helps...

Ok, re-instal helped with that one, but still images not being processed correctly.

I'm not sure if this is anyway related. but I've noticed that if I have multiple redactor entries on a template, elements like the 'add link' button, when rolled over display the 'rollover' options in the bottom redactor entry only, yet it picks up the word from the redactor element you were trying to link from.

This is more than likely a redactor problem itself, and as such I will look into how I can resolve it, but I just thought I would mention a quirk just in-case for some mad reason it is somehow connected.....which I doubt very much.

Thanks for all your help as ever.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I'm not sure I follow your description.

If I have a template with say 3 redactor text areas and say the first one has content and the other two do not. If I select some text in the first redactor text area (highlight) and click the link button, I get two options in a pulldown, one for Insert Link and the other Unlink.

Now, as soon as I mouse over this aforementioned pulldown, it disappears. If I scroll down the screen, I can see that the pulldown has opened for the link button, but in the last of the three textareas.

However, clicking Insert Link from this gives the editing box, with the 'Text' box correctly filled in for the highlighted text.

Not sure why this is happening, yet say, Insert Image works fine.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, I'll see if I can reproduce it.