15 April 2012

ImageMagick Cheat Sheet

The following commands were taken from the internet, I will give acknowledge when found:

Windows version now uses "magick" as the command:

magick vlcsnap-1280-07-14-21h45m00s867.png -crop 400x360+0+0 i1.png


magick ... # in place of `convert`
magick identify ... # in place of `identify`
magick mogrify ... # in place of `mogrify`
magick compare ... # in place of `compare`
magick compose ... # in place of `compose`


--------------------

create thumbnail:
convert -geometry 100x100 -quality 100 orgfilename.jpg thumbfilename.jpg

rotate an image:
convert orgfilename.jpg -rotate 60 rotated60.jpg

croping an image:
convert orgfilename.jpg -crop 128x128+50+50 cropped.jpg
magick filename.jpg -crop 128x128+50+50 cropped.jpg

croping an image for several files:

for file in *.png; do convert -crop 863x675+227+51 "$file" "x6/$file"; done 

convert a directory of png images to gif:
mogrify -format gif *.png
 
mogrify -format webp *.png 

watermarking with text:
convert orgfilename.jpg -font Arial -pointsize 20 -draw "gravity south fill black text 0,12 'Watermark' fill white text 1,11 'Watermark' " wmark_text_drawn.jpg

convert pdf to png
convert pdffile.pdf -colorspace RGB -resample 72×72 -units PixelsPerInch -quality 90 -resize 500×500 -size 500×500 pngfile.png


Convert jpg to pdf
convert *.jpg output.pdf
 

convert input.png PNG24:output.png

convert i00.png -crop 319x160+8+24 PNG24:r00.png

For several images to a single PDF: (yeah, not magick)

img2pdf --out z2.pdf *.png

 

Compression for PNG:

pngquant *.png

PDF too big (from jpg)
convert -quality 60 *.jpg output.pdf


Resize an image:
convert image.jpg -resize 800 image.png
(porcentaje no me funco bien)

mogrify -path xx -resize 800 *.jpg

cd to the directory where your images are located (temp) after creating a new directory to hold the changed files (say, temp2)
mogrify -path fullpathto/temp2 -resize 60x60% -quality 60 -format jpg *.png

Compare to images:
compare image1 image2 -compose src diff.png
estas imagenes pueden ser en diferente formato inclusive ! 
compare PC-200617-1248-30.pdf PC-270717-1119-53.pdf diff.pdf (pdf)
 
Append two images:

convert image1.jpg image2.jpg -append result.jpg 

To verify ImageMagick is working properly, type the following in a Windows Command Prompt window:

convert logo: logo.gif 
identify logo.gif

imdisplay


To see details of the image: (information) 

identify image.ext

identify dp1.jpg
dp1.jpg JPEG 300x374 300x374+0+0 8-bit sRGB 34082B 0.000u 0:00.009

magick identify image

magick identify -verbose r00.png

Invert colors:
convert input.png -channel RGB -negate output.png 


Black & White colors:

convert input.png -colorspace Gray output.png 

Problems with spaces and hyphens in filenames

find . -name "* *" -type f | rename 's/ /_/g'

 ---

Update 2026:

recortar multiples png con command line, seria como un rectangulo.


mkdir -p cropped

for f in *.png; do
    convert "$f" -crop 1800x960+65+95 +repage "cropped/$f"
done

 


 

Robocopy

un muy buen copiador para perifericos que esten con problemas

ROBOCOPY source destination /MIR


   /MIR :: Mirror a complete directory tree.


   /R:n :: number of Retries on failed copies: default 1 million.
   /W:n :: Wait time between retries: default is 30 seconds.


   /S :: copy Subdirectories, but not empty ones.
   /E :: copy subdirectories, including Empty ones.

i.e.:

robocopy C:\development F:\backup\development /r:2 /w:2 /s


(este copia recursivo, reintentando solo 2 veces y si se ejecuta de nuevo excluye a los archivos ya copiados ~mirroring).


Un buen resumen aparece al final:
(tambien podria ser mas verboso)


------------------------------------------------------------------------------
                Total    Copied   Skipped  Mismatch    FAILED    Extras
     Dirs :     11882     11881         1         0         0         0
    Files :    105989    105989         0         0         0         0
    Bytes :   1.541 g   1.541 g         0         0         0         0
    Times :   0:50:42   0:48:38                       0:00:00   0:02:03


    Speed :              567158 Bytes/sec.
    Speed :              32.453 MegaBytes/min.


    Ended : Sun Apr 15 19:33:30 2012

hay varias GUI no-oficiales y una oficial para robocopy, entre ellas: http://betterrobocopygui.codeplex.com/



29 March 2012

JDK 7 8 9 10

The new JDK's will have a new version every two years... now we won't wait for a unknown long time for a new version. Is that good ?

So you can correlate that JDK 10 will be on 2017

Why is this new frenzy creating new version numbering system?
FireFox and Chrome are running fast under this agile versioning...

28 February 2012

Certificaciones Java

Hubo un cambio importante en las certificaciones de Java, ahora hay mas subtipos, aun se mantienen las version par EE5 (siendo EE6 la actual), tambien se agregó J2SE 7, por unz razón obvia se cambió las siglas de ellas (usando el prefijo OC en vez de SC), etc.

Como ya es de costumbre (o mala costumbre) Oracle tiene un nuevo URL para la información de las certificaciones, divididas por capas de negocio: http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=39

Por ejemplo, la antigua SCWCD ahora se convirtió en OCPWCD y su URL es: http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=458&get_params=p_track_id:JEE5WCD


21 November 2011

Elegir: Elige vs Elije

Es uno de los verbos más usado en el comercio a diferentes niveles, tal como, ferias libres, malls, marketing televisivo, Internet, papel (periódicos, carteles y otros).

Elije: incorrecto

A la vez uno de los verbos mas erradamente escritos, sucede muy frecuente que usen J (jota) en vez de G para decir, elegido, elegir... no sé cual es el motivo de confusión, donde la regla es sólo si usan a/o entonces hay que usar J

En la RAE sale la conjugación correcta:


En Transgrediendo a Cervantes hay varias fotos al respecto.

PD: Proteger es otro verbo que también se usa mal a menudo.

08 November 2011

WL_LLR_ADMINSERVER

WebLogic Server 10.x has non-XA datasource that emulates Global Transactions; when using non-XA with Global Transactions and Logging Last Resource enable the following error may happen at admin console:

* An error occurred during activation of changes, please see the log for details.

* weblogic.application.ModuleException:

* JDBC LLR, table verify failed for table 'WL_LLR_ADMINSERVER', row 'JDBC LLR Domain//Server' record had unexpected value 'base_domain//AdminServer' expected 'domain_sample//AdminServer'*** ONLY the original domain and server that creates an LLR table may access it ***

or

in the WLS stdout:

<08-11-2011 10:50:57 AM CLST> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 1 task for the application 'DS1'.>
weblogic.application.ModuleException:
        at weblogic.jdbc.module.JDBCModule.activate(JDBCModule.java:349)
        at weblogic.application.internal.flow.ModuleListenerInvoker.activate(ModuleListenerInvoker.java:107)
        at weblogic.application.internal.flow.DeploymentCallbackFlow$2.next(DeploymentCallbackFlow.java:411)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
        at weblogic.application.internal.flow.DeploymentCallbackFlow.activate(DeploymentCallbackFlow.java:74)
        at weblogic.application.internal.flow.DeploymentCallbackFlow.activate(DeploymentCallbackFlow.java:66)
        at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:635)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
        at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
        at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:16)
        at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:162)
        at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
        at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
        at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:140)
        at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:106)
        at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)
        at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:820)
        at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1227)
        at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:403)
        at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163)
        at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:181)
        at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.commit(DeploymentReceiverCallbackDeliverer.java:63)
        at weblogic.deploy.service.internal.statemachines.targetserver.AwaitingCommit.callDeploymentReceivers(AwaitingCommit.java:235)
        at weblogic.deploy.service.internal.statemachines.targetserver.AwaitingCommit.handleCommit(AwaitingCommit.java:131)
        at weblogic.deploy.service.internal.statemachines.targetserver.AwaitingCommit.receivedCommit(AwaitingCommit.java:44)
        at weblogic.deploy.service.internal.transport.CommonMessageReceiver.receiveRequestCommitMsg(CommonMessageReceiver.java:470)
        at weblogic.deploy.service.internal.transport.CommonMessageReceiver$3.run(CommonMessageReceiver.java:742)
        at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: java.sql.SQLException: JDBC LLR, table verify failed for table 'WL_LLR_ADMINSERVER', row 'JDBC LLR Domain//Server' record had unexpected value 'base_domain//AdminServer' expected 'domain_sample//AdminServer'*** ONLY the original domain and server that creates an LLR table may access it ***
        at weblogic.jdbc.wrapper.JTSLoggableResourceTable.newVerifyException(JTSLoggableResourceTable.java:221)
        at weblogic.jdbc.wrapper.JTSLoggableResourceTable.findOrCreateTable(JTSLoggableResourceTable.java:303)
        at weblogic.jdbc.wrapper.JTSLoggableResourceImpl.findOrCreateBackingTable(JTSLoggableResourceImpl.java:528)
        at weblogic.jdbc.wrapper.JTSLoggableResourceImpl.recoverXARecords(JTSLoggableResourceImpl.java:241)
        at weblogic.transaction.internal.ServerTransactionManagerImpl.registerLoggingResourceTransactions(ServerTransactionManagerImpl.java:751)
        at weblogic.jdbc.common.internal.RmiDataSource.recoverLoggingResourceTransactions(RmiDataSource.java:277)
        at weblogic.jdbc.common.internal.DataSourceManager.createAndStartDataSource(DataSourceManager.java:148)
        at weblogic.jdbc.common.internal.DataSourceManager.createAndStartDataSource(DataSourceManager.java:97)
        at weblogic.jdbc.module.JDBCModule.activate(JDBCModule.java:346)
        ... 29 more

This is for the verbatim message:

Caused by: java.sql.SQLException: JDBC LLR, table verify failed for table 'WL_LLR_ADMINSERVER', row 'JDBC LLR Domain//Server' record had unexpected value 'base_domain//AdminServer' expected 'domain_sample//AdminServer'*** ONLY the original domain and server that creates an LLR table may access it ***

Therefore one way to solve this is to update the WL_LLR_ADMINSERVER table pointing to to the correct target domain name and server that has this LLR DataSource.
where the String 'domain_sample//AdminServer' is the tuple to be modifed.

Excute the following SQL script for updating:

update SCHEMA_SAMPLE.WL_LLR_ADMINSERVER set RECORDSTR = 'domain_sample//AdminServer' where  XIDSTR  = 'JDBC LLR Domain//Server'; 

02 November 2011

Eclipse Plug-ins (update)

After several years, many plug-ins have been made and are more stable than ever.

From my last post about it, the following list is the one I am currently using:
(most of these URIs are the repository location for installing new software at Eclipse)
More plug-ins can be found at:  http://marketplace.eclipse.org/

28 October 2011

org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken

In Oracle Weblogic Server - Version: 9.2 to 10.3.6 when shutting down managed server(s) the following error may occurs:

CharScanner; panic: ClassNotFoundException: org.hibernate.hql.ast.HqlToken

or when trying to run an application using HQL with antlr as parser, the following stacktrace may appear:

org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [ from org.example.hibernate.Customer]
at org.hibernate.hql.ast.HqlLexer.panic(HqlLexer.java:57)
at antlr.CharScanner.setTokenObjectClass(CharScanner.java:340)
at org.hibernate.hql.ast.HqlLexer.setTokenObjectClass(HqlLexer.java:31)
at antlr.CharScanner.(CharScanner.java:51)
at antlr.CharScanner.(CharScanner.java:60)
at org.hibernate.hql.antlr.HqlBaseLexer.(HqlBaseLexer.java:56)
at org.hibernate.hql.antlr.HqlBaseLexer.(HqlBaseLexer.java:53)
at org.hibernate.hql.antlr.HqlBaseLexer.(HqlBaseLexer.java:50)
at org.hibernate.hql.ast.HqlLexer.(HqlLexer.java:26)
at org.hibernate.hql.ast.HqlParser.getInstance(HqlParser.java:44)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:242)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:112)
at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:57)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1627)
at org.example.hibernate.HQLSample.selectCustomer(HQLSample.java:41)
at Test.doGet(Test.java:38)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:821)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:184)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3717)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

Cause
Classloading issues with antlr library bundled with WebLogic Server that is not compatible with Hibernate 3.

Solution
It is necessary to use antlr 2.7.6 (this version works, however more details of which version should be check with Hibernate as being a third party tool).

There are 4 possible workarounds for this classloading issue:

1. Package antlr.jar into WEB-INF/lib and add the following tag to weblogic.xml
    (this works for war alone or packaged into an ear).
<container-descriptor>
    <prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>

2. If it is an ear file then put antlr.jar at APP-INF/lib (or at web application level: WEB-INF/lib) and modify weblogic-application.xml adding the following tag:
<prefer-application-packages>
    <package-name>antlr.*</package-name>
</prefer-application-packages>

3. Change property hibernate.query.factory_class from hibernate configuration file (hibernate.cfg.xml).
    (if hibernate.query.factory_class doesn't exist then this value is assigned by default):
<property name="hibernate.query.factory_class"
 value="org.hibernate.hql.ast.ASTQueryTranslatorFactory">
</property>

to a different parser (classic):

<property name="hibernate.query.factory_class" 
value="org.hibernate.hql.classic.ClassicQueryTranslatorFactory">
</property>

4. Set at server classpath level antlr library before WLS classpath.
    (warning: this is the less recommended option because it impacts the whole WLS and may affect another modules).

    In setDomainEnv.cmd (or any of the start-up scripts) set the next value at the end of the file, referring to antlr library's location:

set CLASSPATH=C:\jars\antlr-2.7.6.jar;%CLASSPATH%

References
http://download.oracle.com/docs/cd/E21764_01/web.1111/e13706/classloading.htm
http://community.jboss.org/wiki/HibernateCoreMigrationGuide30#weblogic

25 October 2011

Matemática, un viaje entretenido

Para los usuarios del Metro de Santiago de Chile hay un concurso de matemáticas que esta abierto hasta el 31 de octubre.

Son preguntas interesantes y alguna conocidas... si se entusiasman vayan al sitio: http://www.unviajeentretenido.cl

Se agradece esta iniciativa hecha por el Metro y la PUC.

Blog Archive

Disclaimer

Qux