Menu
  • HOME
  • TAGS

How to skip unsupported image using cfimage processing?

Tag: coldfusion,coldfusion-10,cfml

I am using ColdFusion 10. When trying to read some image files, ColdFusion returns no values and no error messages are shown.

I tried to re-size an image using cfimage tag. It is crashing. So I tried to get info about the image using "imageinfo" function. It returns blank. Please help me to either get some info or skip the image. Can anyone help me?

I tried reading the file which caused the anomaly using

<cfimage action="read" source="full pathname" name="image">
<cfset image = imageRead(full pathname)>

and many other ColdFusion documented functions. No error was shown. No output was obtained. I used cffile which showed unsupported file type error.

<cffile
    action = "readBinary" file = "full pathname" variable = "variable name"
>

Thanks Rino

Best How To :

Try using this function for reading images.

CFimage tag or imageNew() can have issues while trying to read image files which are corrupted or files saved with changed extensions (background transparent .png files saved as .jpeg) while uploading.

I think the main problem with these files is that there is a chance coldfusion doesn't throw an error of any sort when we try to read files mentioned above.

<cfscript>
    public function readImage(fullpath){
        //trying java imageio
        var imageFile = createObject("java", "java.io.File").init(fullpath); 
        // read the image into a BufferedImage
        var ImageIO = createObject("java", "javax.imageio.ImageIO");
        try {
            var bi = ImageIO.read(imageFile);
            return ImageNew(bi);
        } catch(any e) {
        //try for bad formatted images
            //create java file object, passing in path to image
            var imageFile = createObject("java","java.io.File").init(fullpath);
            //create a FileSeekableStream, passing in the image file we created
            var fss = createObject("java","com.sun.media.jai.codec.FileSeekableStream").init(imageFile);
            //create ParameterBlock object and initialize it (call constructor)
            var pb = createObject("java","java.awt.image.renderable.ParameterBlock").init();
            //create JAI object that will ultimately do the magic we need
            var JAI = createObject("java","javax.media.jai.JAI");
            try {
                //pass in FileSeekableStream
                pb.add(fss);

                //use the JAI object to create a buffered jpeg image.
                var buffImage = local.JAI.create("jpeg", pb).getAsBufferedImage();

                //pass the buffered image to the ColdFusion imagenew()
                var New_Image = imagenew(buffImage);

                //make sure we close the stream
                fss.close();
                return New_Image;
            } catch (any e) {
                if (isDefined("fss")) {
                    fss.close();
                }
                rethrow;
            }
        }
    }
</cfscript>

Hashed password sometimes longer than 128 characters

coldfusion

It seems from your error that the issue is at a database level, as ColdFusion is not failing your maxlength check on the cfqueryparam tag and is allowing the query to be executed. I just tested trying to pass a string that exceeds the length specified in the maxlength attribute...

How can I send this XML request to my server and have it send to and get a response from another server

xml,https,coldfusion

Try this... First, save the packet. <cfsavecontent variable="theXMLPacket"> <cspinput appID="asdfasdf" appPassword="asdf1234" > <account userid="johndoe" action="authenticate"> <password>mypasswd1234</password> </account> </cspinput> </cfsavecontent> Then we use cfhttp to post it to the processing server. <cfhttp method="post" url="https://someurl.com/endpoint" result="xmlResult"> <cfhttpparam type="xml" value="#XMLParse(theXMLPacket)#" /> </cfhttp> Then process the...

Get number of files in various subdirectories relative to the current page - ColdFusion

coldfusion,directory,cfdirectory

This code should work. <cfoutput> directory="#GetDirectoryFromPath(GetTemplatePath())#" </cfoutput> <cfdirectory directory="#GetDirectoryFromPath(GetTemplatePath())#" name="myDirectory" sort="name ASC, size DESC, datelastmodified" recurse = "yes"> <!---- Output the contents of the cfdirectory as a cftable -----> <cftable query="myDirectory" colSpacing = "10" htmltable colheaders> <cfcol header="Count" align="left" width="20" text="#recordCount#"> <cfcol header="NAME:" align = "Left" width = 20...

Concatenate form element name with coldfusion counting variable

forms,coldfusion

You're mostly there <cfqueryparam cfsqltype="cf_sql_char" value="#form['setID' & i]#"> ...

Form Data Not Being Sent In ColdFusion

forms,coldfusion

You need to enclose the userid between cfoutput so that it can be evaluated. Or better just wrap the form inside cfoutput. <cfoutput> <form action="storage.cfm" method="POST"> <input type="hidden" name="userId" value="#userId#"> <label>First Name:</label> <input type="text" name="firstName" value="#firstName#"> <label>Last Name:</label> <input type="text" name="lastName" value="#lastName#"> <label>Address:</label> <input type="text" name="address" value="#address#">...

ColdFusion DateDiff - Is there a better way?

mysql,coldfusion,datediff,simplify

The solution to improving the code posted for ColdFusion was actually replacing it. By adding the hire_dates of each member to an existing MySQL database and writing the query below; I no longer needed all of the ColdFusion code in my original post. SELECT SUM(TIMESTAMPDIFF(YEAR,hire_date,NOW())) AS Dif FROM members WHERE...

Dynamic bootstrap active tab

coldfusion,bootstrap,tabpanel

You can give this a try: <div role="tabpanel"> <!-- Nav tabs --> <ul class="nav nav-tabs" role="tablist"> <cfoutput query="lessons" group="lesson_date"> <li role="presentation" <cfif lessons.currentRow EQ 1>class="active"</cfif>> <a href="###DateFormat(lesson_date, 'ddddd')#" aria-controls="#DateFormat(lesson_date, 'ddddd')#" role="tab" data-toggle="tab" >#DateFormat(lesson_date, 'ddddd')#, #DateFormat(lesson_date, 'd')# #DateFormat(lesson_date, 'mmmm')# </a> </li>...

Is it possible to use C++ CFX tags in Railo?

coldfusion,railo

Railo 4.2 is supposed to be compatible with CF 10 but it doesn't support C++ tags. It's intended to be compatible as far as cfml syntax goes but there are however a few things railo doesn't support, c++ cfx tags being one of them. It does support Java CFX tags....

ColdFusion Function Error (cfc)

coldfusion-10,cfc

If your catch block is executed, there would be no return. Maybe you want to return false as the last line of your cfcatch. Otherwise put the cfreturn true as the last line of the function. Can you verify that catch block is not being executed?

executing cfquery in cfc with parameters received via AJAX [duplicate]

javascript,ajax,coldfusion

Give this a try: <cfquery name="query" datasource="phonebook"> SELECT '#select#' FROM '#from#' WHERE '#where#' ORDER BY '#orderBy#' </cfquery> As I recall from my research, putting the quotes around the variables tells coldfusion that it should process those values in a sql-like manner. That is, it won't escape the quotes you are...

How to get old Coldfusion MX7 Serial Number In FileSystem

coldfusion,serial-number,coldfusion-7

Details from this forum discussion here: https://forums.adobe.com/thread/1154153 Find the [cf_root]\lib\license.properties file. The serial number is on the line beginning sn=...

SessionTimeout not overrriding CF Administrator

coldfusion

Per the ColdFusion documentation: " you cannot set a time-out value [in Application.cfc or Application.cfm] that is greater than the maximum session time-out value set on the Administrator Memory Variables page." Since you are on shared hosting, if your host won't increase the timeout (and they probably won't), you're going...

How to check at least 1 check box is check before submitting form? [duplicate]

coldfusion

Assuming you're using jQuery, you can do the following: // when the form submit event occurs $("#confrm_key").submit( function( event ) { // if we don't have any checked checkboxes if ( $(this).find(":checked").length === 0 ) { // throw an alert alert( "Warning message here." ); // and stop the submission...

SublimeText 3 - Package Control: Removed directory for orphaned package ColdFusion

coldfusion,sublimetext3,sublimetext,sublime-text-plugin

The "Download Manually" section is for Sublime Text 2 only. At the very top of the README you linked are the ST3 instructions: The development branch contains a rewrite of the ColdFusion plugin. The only installation method is via Git. cd Packages/ git clone https://github.com/SublimeText/ColdFusion.git cd ColdFusion git checkout development...

Coldfusion 9 serializeJSON()

json,coldfusion,adobe,coldfusion-9,cfml

You can disable this in the ColdFusion administrator. Go to Server Settings > Settings and uncheck Prefix serialized JSON with There are, however, security implications if you turn this off. This helps protect your JSON data from cross-site scripting attacks and is explained more in depth in this StackOverflow answer...

Coldfusion CFGRID started showing as empty

coldfusion,coldfusion-8

Assuming that, you are using the latest version of ColdFusion(CF 11), I tried with querysetcell and your cfgrid code. The below code works in all browsers. <cfset rsPages = querynew("pageID, pageCountryID, pageLanguageID, pageName, pageTitle")> <cfset queryaddrow(rsPages, 3)> <cfset querysetcell(rsPages,"pageCountryID","Country1",1)> <cfset querysetcell(rsPages,"pageLanguageID","Language1",1)> <cfset querysetcell(rsPages,"pageName","Page1",1)> <cfset querysetcell(rsPages,"pageTitle","Title1",1)>...

code optimizing in coldfusoin, as String are immutable in Coldfusion

coldfusion,coldfusion-9

This would perhaps be an approach. it's a complete stand-alone repro, but the bit you want to look at is the listAppend() stuff: <cfscript> qRoute = queryNew(""); queryAddColumn(qRoute, "a", "varchar", ["","a2","a3","a4"]); queryAddColumn(qRoute, "b", "varchar", ["","","b3","b4"]); queryAddColumn(qRoute, "c", "varchar", ["","","","c4"]); </cfscript> <cfloop query="qRoute"> <cfif not len(qRoute.a)> <cfcontinue> </cfif> <cfset str =...

Passing Coldfusion Form Values to javascript and CFC , code not working

javascript,jquery,ajax,coldfusion

I was able to resolve the issue which had to do with resolving the path to the cfc. Working code is below. Solution: AJAX: <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> <script language="javascript"> $(document).ready(function() { $("#createReport").click(function(f) { var getReportName = $("input#reportName").val(); var getReportPath = $("input#reportPath").val(); var getReportDesc = $("input#reportDescrip").val(); //var getCategory = $("input#categoryBox").val(); $.ajax({...

How to get raw binary from hash function in ColdFusion 9?

coldfusion,coldfusion-9,sha

Since you know the hashed string is in hex, simply decode it with the aptly named binaryDecode() function. hashedString = hash("bob", "SHA1"); binaryData = binaryDecode(hashedString , "Hex"); ...

Confusion on when to use cfoutput in cfmail

coldfusion,cfoutput

You don't need it, unless perhaps you're doing looped output of a cfquery. e.g. if your emailformData query returned multiple rows (and it obviously doesn't), you might do: <cfmail ...> Here's the email data #form.name# asked for: <cfoutput query="emailformData"> #emailformData.Sold_to_Party# </cfoutput> Sent on #dateFormat(now())# </cfmail> See Sample uses of the...

Decoding Base64 to an Image in ColdFusion

javascript,coldfusion,cfml,topaz-signatures

As your binary data doesn't have image headers(Contains Mime type e.g. data:image/png;base64 for png image) so you can simply use imageReadBase64 like this: <cfset image = imageReadBase64(form.SigImgData)> <cfimage source="#image#" destination="c:\Inetpub\wwwroot\signatures\#fullfilename#.bmp" action="write"> I tried it locally with same code. Is this your image? ...

Error Executing Database Query (issue with WHERE clause?)

sql-server-2008,coldfusion

It's because the way you're building your SQL statement you've got values hard-coded amongst the SQL itself, ie: <cfset strWhere = " WHERE SCHYEAR = '#Form.yrVal#'"> This has both SQL in it: WHERE SCHYEAR = and a value: '#Form.yrVal#'. One shouldn't really do that, and indeed when your values are...

Data Link Escapes and Other Nonprintable Characters

coldfusion,sublimetext3,control-characters

In general these can be created with the chr() function. It is useful for creating many the non printable characters. One of the more common usages is to crea See: https://wikidocs.adobe.com/wiki/display/coldfusionen/Chr As for DLE, you can <cfset DLE = chr(16)> Another common usage is to create Carriage Return / Line...

How to sanitize form values to allow text-only

coldfusion,sanitization,coldfusion-11,antisamy

While you could use AntiSamy to do it, I don't know how sensible that would be. Kinda defeats the purpose of it's flexibility, I think. I'd be curious about the overhead, even if minimal, to running that as a filter over just a regex. Personally I'd probably opt for the...

Change the List delimiter to something new

coldfusion

That is the definition of delimiter. Anyway, it is relatively easy to fix, just add the last one yourself. <cfset foo="t,u,n,f,o,a,c,r,v"> <cfset msg = ListChangeDelims(foo,'="",')> <cfset msg &= '=""'> <cfoutput>#msg#</cfoutput> http://trycf.com/gist/4ac3702b74bd79b5d1f8/...

Match a single senerio with ANTLR and skip everything else as noise

java,parsing,coldfusion,antlr

You can use lexer mode to do what you want. One mode for property and stuffs and one mode for noise. The idea behind mode is to go from a mode (a state) to another following token we found during lexing operation. To do this, you have to cut your...

Display single digits with leading zero

coldfusion

You can use numberFormat. <select id="minutes"> <cfoutput> <cfloop from="1" to="60" index="m"> <option>#numberFormat(m,'00')#</option> </cfloop> </cfoutput> </select> See also this runnable example at trycf.com....

ColdFusion Component Not Returning Query

coldfusion,cfc

Your cfinvoke is missing a returnVariable <cfinvoke component="queries" method="EmployeeQuery" returnVariable="EmployeeAdd"> <cfinvokeargument name="EmployeeID" value="#form.txtEmployeeID#"> </cfinvoke> <h3>Confirm Employee Entered</h3> <cfoutput>#EmployeeAdd.displayName#</cfoutput> Alternatively if you're on CF10 or higher you could do this instead of your cfinvoke <cfset employeeAdd = new queries().EmployeeQuery(form.txtEmployeeID)> ...

How to skip unsupported image using cfimage processing?

coldfusion,coldfusion-10,cfml

Try using this function for reading images. CFimage tag or imageNew() can have issues while trying to read image files which are corrupted or files saved with changed extensions (background transparent .png files saved as .jpeg) while uploading. I think the main problem with these files is that there is...

Assigning Loop Number to a Phrase

coldfusion

Your best bet assuming the count can't up too high is to create an array to pull in the name numberMapping = ['First','Second','Third','Fourth','Fifth','Sixth']; Then update your owner to pull based on your array <legend>Owner <cfoutput>#numberMapping[Peoplecount]#</cfoutput>'s Information</legend> ...

How to write a Javascript function to update a Coldfusion form display

javascript,jquery,coldfusion,coldfusion-9

The solution to this is as follows: Change the form type from Flash to HTML. Eliminate the CFformlayout tags as they will just create a bigger headache than necessary. The following code provides a working coldfusion function and javascript call: AJAX: <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> <script language="javascript"> $(document).ready(function() { $("#createReport").click(function(f) {...

Converting a json looking simple value string to a ColdFusion structure

coldfusion,stripe-payments

Something's wrong in your CF or web server setup. I tested your json with CF11 on tryCF and it works. <cfscript> json = '{ "id": "ch_6HAwRK92OsQPoA", "object": "charge", "created": 1432149035, "livemode": false, "paid": true, "status": "paid", "amount": 100, "currency": "usd", "refunded": false, "source": { "id": "card_6HAwNGtbdzFdq0", "object": "card", "last4": "4242",...

ColdFusion Builder 3 vs. Dreamweaver & local and remote paths

eclipse,iis,coldfusion,development-environment

I really don't mind this question even though it's not directly code related because I've been using ColdFusion Builder (CFB) for years and there just isn't enough good documentation out there. I now enjoy a great experience with CFB thanks to blog posts and sharing experiences with other devs :)...

If null statement in ColdFusion

coldfusion

You're evaluating the len(trim()) of the string "session.checkout.vehicle.makeCodeNumber" not the value of the variable session.checkout.vehicle.makeCodeNumber. You need to remove your " in your second if statement <cfif isDefined("session.checkout.vehicle.makeCodeNumber")> <cfif len(trim(session.checkout.vehicle.makeCodeNumber))> <cfpdfformparam name="make" value="#session.checkout.vehicle.makeCodeNumber#"> <cfelse> <cfpdfformparam name="make" value="#session.checkout.vehicle.vehiclemake#">...

Process ColdFusion Form with Component

forms,function,methods,coldfusion,cfc

A simple way to accomplish what you appear to want is to submit the form to the page containing it. No ajax required. <cfif StructKeyExists(form, "aKnownFormField")> code to process form can use create object to access cfc code if you want </cfif> <form action="thePageIAmOn.cfm" method="post"> <input name="aKnownFormField" type = "text">...

using a query as an argument to a cffunction

coldfusion,cffunction

The version of the question that I posted wasn't actually a carbon copy of the function in the source file. The function in the source actually had some <cfargument> tags (the first one being name="select") that were commented out. I was commenting them like this: <!-- a comment --> which...

Coldfusion Link To Previous Page Remembers Text,Radio, and Dropdowns that were chosen

coldfusion

Radio What you need is: <input id="gender" name="gender" type="radio" value="Male" <cfif isDefined("form_gender") AND form_gender EQ "Male" >checked</cfif> />Male Note: You changed the value field in your example. But you don't want to do that: The value for the field labeled as "Male" should be "Male", and the value for the...

How to identifiy date string vs date object

coldfusion,coldfusion-10

You can leverage the fact that all CFML objects are also Java objects, and use Java methods: myDateString = '2015-05-05'; myDateObject = createDate( 2015, 5, 5 ); writeOutput(myDateString.getClass().getName()); writeOutput("<br>"); writeOutput(myDateObject.getClass().getName()); This yields: java.lang.String coldfusion.runtime.OleDateTime ...

How to get the recordcount of JSON results returned from Coldfusion Component?

json,coldfusion

Unless there is something you are not telling us, you do not need to include an extra row count. It can be derived from the result. By default serializeJSON(queryObject) returns a structure with two keys: DATA and COLUMNS (both arrays). DATA represents the rows in the query. So to obtain...

Create a simple unit tests framework from scratch in Coldfusion

unit-testing,coldfusion,frameworks,coldfusion-9

In answer to your question, it sounds like you want to inject variables / methods into the subject under test. You can do it like so: myInstance["methodName"] = myFunction; You can then call the injected method like so: myInstance.myFunction(); Both MXUnit and TestBox use this technique. Having said that I...

How to get list of valid tags of Jsoup whitelist?

java,coldfusion,jsoup

If you want to go the reflection route, you can do something like below which grabs access to the tagNames set, converts it to an array of org.jsoup.safety.Whitelist$TagName objects (which contain the tag names) and then appends the toString() values of those objects to another array. <cfscript> whitelist = createObject("java",...

Compressing a PDF document generated by coldfusion

pdf,coldfusion,coldfusion-8,pdf-conversion

CFDocument generates bloated PDFs. We tested GhostScript and used the following parameters to compress a 22.3mb PDF to 4mb. (If set to "screen", the file size shrunk down further to 2.5mb.) http://www.ghostscript.com/ To use this, you'll have to perform this optimization as an extra step after the generation of your...

Use java class in ColdFusion11 - The java object type is unknown for the CreateObject function

coldfusion,coldfusion-10,railo,cfwheels

Ah thanks all. As haxtbh said in the comments, the problem was Adobe CF's createObject only has two arguments. The type and the class. So I needed to put: this.javaSettings = { LoadPaths = ["/miscellaneous"] }; in /config/app.cfm and then use CreateObject( "java", "BCrypt" ); in /events/onapplicationstart.cfm ...

Read substring between two strings CF

regex,coldfusion,coldfusion-9

You are on the right track.. just make your .* greedy by adding ?.. and exclude trailing space by adding \s* after it. actuals_ADAPS_20150517_3\.t&gt;<\/A>\s*(.*?)\s*4k See DEMO...

JSOUP - How to get list of disallowed tags found in html?

coldfusion,jsoup,whitelist

I don't believe there's a direct function in jsoup to get a list of the invalid elements based on your whitelist. You'd have to roll your own. It's not overly complicated. You can still work from a Document object, select all of the elements and then individually check them against...

How to get associative arrays notation to assign simple values

coldfusion,coldfusion-11

@Leigh is correct in that you need to supply the row number when using associative array notation with a query object. So you'd reference row 1 like: qryNWProducts[vcColName][1] As for your question Is this the best way to transfer the simple values from a query to a structure? Are you...

How Do you Reference Coldfusion Instances in Clustered Server Environment

coldfusion,instance

Two methods I've used are to either include an HTTP header in the response, or an HTML comment that outputs the name of the server so you can view it with debugging tools. No, on to your specific question about the instance, you haven't said what ever of CF engine...

ColdFusion ~ Class must not be an interface (OSX only)

java,osx,coldfusion

The direct access could be working for some of the classes and not for others because the ones it is not working for may be expecting helper classes to be in the classPath. Adding the path to the location of your Google API Java files to your jvm.config file (example...